View Full Version : Simple Controls Gallery image link

02-20-2011, 09:21 PM
1) Script Title: Simple Controls Gallery

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/simplegallery.htm

3) Describe problem: I have embedded the script in this page:www.17minutes.f2s.com/Gallery2.htm
I understand that the images can be hyperlinked. i would like to use this facility to open a new window with the relevant clicked image in for printing. I have tried to call a function I have written before:


function BigPhoto(source){
var source
var newWindow = window.open("", "",
"location=no, directories=no, fullscreen=no, menubar=no, status=no, toolbar=no, width=900, height=600, scrollbars=no");
newWindow.document.write("<BODY BGCOLOR=#000000 LINK=#FFFFFF>");
newWindow.document.write("<a = 'javascript:window.refresh()'></a>")
newWindow.document.write("<img src='" + source + "'/><br>");


but I don't know how to code calling the function and passing the "source" parameter to the function.
Another option would be to make a new page, say called PrintImage, and link to it from the image and define it's source as part of the link so the page opens to display the image for printing.

Any thoughts please, my heads spinning!

Cheers, Lol

02-22-2011, 04:50 PM
This will open the image once clicked in a new window
<a href="./images/002.jpg" target="_blank"><img src="images/img002.jpg" id="Image1" alt="" border="0" style="width:603px;height:369px;"></a>

02-22-2011, 05:16 PM
Hi, the problem I have is that the hyperlink is enclosed in quotes as part of the image gallery source code and is either, say, PrintImage.htm for a local page or http:// etc for an external one. trying to add other information such as an img src just stalls the gallery altogether. tricky,no?

02-22-2011, 05:29 PM
well, I'm not sure I understand your requirements correctly, but maybe you could make the imagaarray like this:

["Samurai/001.jpg", "http://www.17minutes.f2s.com/Samurai/001.jpg", "_new", ""],

02-22-2011, 06:30 PM
azoomer that worked brilliantly! This is what I have been banging my head against the wall with. Now, if I could somehow format the new page i.e change background colour, centre image. Also, it would be useful for it to call the print command on bodyload and then printwindow.
I have come up with a rudimentary solution by assigning a page to EVERY image. This is okay, but there could be 300 images! This is the code I have used in the page I have created so far and it works great, clicking on the first image in the gallery www.17minutes.f2s.com/Gallery4.htm brings up a new page, asks for print permission and then on a timer closes down returning to the original flash gallery

<body onLoad="window.print()">
<script type="text/javascript" language="javascript">




As I said, being able to create the page dynamically would be brilliant.
Cheers, Lol

02-22-2011, 10:58 PM
Right I've looked into the source file, simplegallery.js, and identified the array code and how it handles the images in terms of links etc
element[0] is the source to view
element[1] is the link address for any hyperlinking
element[2] is the target
element[3] is for any sort of text

the actual code is:


var layerHTML=(imgelement[1])? '<a href="'+imgelement[1]+'" target="'+imgelement[2]+'">\n' : '' //hyperlink slide?
layerHTML+='<img src="'+imgelement[0]+'" style="border-width:0" />'
layerHTML+=(imgelement[1])? '</a>' : ''
return layerHTML //return HTML for this layer

In the array in my webpage I would like to leave element[0] as it is, typically "001.jpg"
Set element[1] to "PrintImage.htm" with it's image source set to "Large/"+element[0] - a larger version of "001.jpg".

I can't do javascript so would appreciate some help to code this properly if possible?
Thanks, Lol