Below is working Javascript code that displays a full-sized image in a pop-up window when a thumbnail image is clicked on.
I like this code because: 1) a single window is used to display pictures; 2) even if the window is minimized, the window is made visible when an image is clicked on; 3) the window automatically closes when moving to a different web page.
PROBLEM is that I can't seem to pass the title of a picture (associated with each photo) to the pop up window. Any thoughts on how to fix this?
Working code below, just cut -n- paste:
<HTML>
<Title>Insert title of page here</Title>
<HEAD>
<TITLE>Pop-up Image Window</TITLE>
<!----- Pop-up images functions ------------------------------------------>
<SCRIPT Language="JavaScript">
<!--
var pic = null
var popImg = null // use this when referring to pop-up image
var picTitle = null
var imgCount = 0
var imgWinName = "popImg"
function openPopImg(picName, windowTitle, windowWidth, windowHeight){
closePopImg()
picTitle = windowTitle
imgWinName = "popImg" + imgCount++ //unique name for each pop-up window
popImg = window.open(picName, imgWinName,
"toolbar=no,scrollbars=no,resizable=no,top=200,left=340,width="
+ (parseInt(windowWidth)+0) + ",height="
+ (parseInt(windowHeight)+0))
}
function closePopImg(){ // close pop-up window if it is open
if (navigator.appName != "Microsoft Internet Explorer"
|| parseInt(navigator.appVersion) >=4) //do not close if early IE
if(popImg != null) if(!popImg.closed) popImg.close()
}
function setStatus(msg){
status = msg
return true
}
//-->
</SCRIPT>
</HEAD>
<BODY onUnload="closePopImg()">
<P>
<A HREF="JAVASCRIPT
penPopImg(' 'Window title for large1 jpeg', '400', '300')"><img src=" alt="Name of Image1 if missing" border=0></A>
<A HREF="JAVASCRIPT
penPopImg(' 'Window title for large2 jpeg', '400', '300')"><img src=" alt="Name of Image2 if missing" border=0></A>
</P>
</BODY>
</HTML>
I like this code because: 1) a single window is used to display pictures; 2) even if the window is minimized, the window is made visible when an image is clicked on; 3) the window automatically closes when moving to a different web page.
PROBLEM is that I can't seem to pass the title of a picture (associated with each photo) to the pop up window. Any thoughts on how to fix this?
Working code below, just cut -n- paste:
<HTML>
<Title>Insert title of page here</Title>
<HEAD>
<TITLE>Pop-up Image Window</TITLE>
<!----- Pop-up images functions ------------------------------------------>
<SCRIPT Language="JavaScript">
<!--
var pic = null
var popImg = null // use this when referring to pop-up image
var picTitle = null
var imgCount = 0
var imgWinName = "popImg"
function openPopImg(picName, windowTitle, windowWidth, windowHeight){
closePopImg()
picTitle = windowTitle
imgWinName = "popImg" + imgCount++ //unique name for each pop-up window
popImg = window.open(picName, imgWinName,
"toolbar=no,scrollbars=no,resizable=no,top=200,left=340,width="
+ (parseInt(windowWidth)+0) + ",height="
+ (parseInt(windowHeight)+0))
}
function closePopImg(){ // close pop-up window if it is open
if (navigator.appName != "Microsoft Internet Explorer"
|| parseInt(navigator.appVersion) >=4) //do not close if early IE
if(popImg != null) if(!popImg.closed) popImg.close()
}
function setStatus(msg){
status = msg
return true
}
//-->
</SCRIPT>
</HEAD>
<BODY onUnload="closePopImg()">
<P>
<A HREF="JAVASCRIPT
<A HREF="JAVASCRIPT
</P>
</BODY>
</HTML>