/    Sign up×
Community /Pin to ProfileBookmark

Image Gallery with popup window

I am trying to create a gallery page, that uses an array to open the pictures into a popup window pic_open.html.
The image and description I selected then is opened in the popup window.

I did receive the following code but it doesnt seem to work for me ??? Have I missed something. Please help.

<SCRIPT LANGUAGE=”JavaScript”>
function crtImage(img,desc,x,y) {
this.img=img;
this.desc=desc;
this.x=x;
this.y=y;
// optional preload of image comment out if not needed
z=new Image(); z.src=img;
}

var myImages = new Array(
new crtImage(‘production_pic_0.jpg’,’description of image 0′,400,600),
new crtImage(‘production_pic_1.jpg’,’description of image 1′,500,475),
new crtImage(‘production_pic_2.jpg’,’description of image 2′,300,243)
)
function newWindow(idx) { // note the extra space, for description for example

window.open(‘pic_open.html?’+idx,’win’+idx,’width=’+(myImages[idx].y+20)+’,height=’+myImages[idx].x+40);
}
</SCRIPT>
<td width=”25%”><a href=”#”
onClick=”newWindow(0); return false”><img src=”graphics/thumb_pic_0.jpg”
width=”117″ height=”75″ border=”0″></a></td>

<td width=”25%”><a href=”#”
onClick=”newWindow(1); return false”><img src=”graphics/thumb_pic_1.jpg”
width=”117″ height=”75″ border=”0″></a></td>

then in the pic_open.html have

<script>
passed = location.search.substring(1);// drop the leading “?”
document.write(‘<center><img
src=”‘+opener.myImages[passed].img+'”><br>’+opener.myImages[passed].desc+'</center>’)
</script>

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @got2lurveit spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...