Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

image source in a popup window

Status
Not open for further replies.

howdoesthiswork

Technical User
Sep 24, 2002
18
NA
Greetings
I have just created an Image gallery for a client. When clicking on a thumbnail image a popup opens with the larger version of the same image shown. Seeing that there are quite a few of them, I don't want to write a html page for each one. Somehow the javascript needs to tell wich image to insert into the popup depending on which thumbnail was clicked.
Hope this makes sense ....
 
Hi

This is what I did in a similar situation

function popup(image) {
win = window.open('', '', 'toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,top=50,left=50,height=450,width=650');
win.document.open();
win.document.write(&quot;<html><head><title>View Image</title></head>&quot;);
win.document.write(&quot;<body><img src=&quot;+image+&quot;></body></html>&quot;);
win.document.close();
}

Then to each thumbnail add

<a href=javascript:popup('pathtolargeimage')>

Hope this helps

--------------------------------
If it ain't broke, don't fix it!
 
It works ...
Great thanx a lot. One question though, I have created one popup html file (it has image decorations, coloured background etc.) how would I use that file and load the relevant large image into it?
 
just view source of the page you have created for your popup, and change it into a series of win.document.write(); like gpzcrasher used:
Code:
win.document.write(&quot;<html><head><title>View Image</title></head>&quot;);

just use one for every line in your .html file




Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
Aaaahh thanx ...

Its weird how sometimes the easiest solutions elude us ...

Thanx a lot guys ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top