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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass a Window Title to a Pop-up Window

Status
Not open for further replies.

Ineedjava

Technical User
Apr 14, 2001
21
US
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=&quot;JavaScript&quot;>
<!--

var pic = null
var popImg = null // use this when referring to pop-up image
var picTitle = null
var imgCount = 0
var imgWinName = &quot;popImg&quot;

function openPopImg(picName, windowTitle, windowWidth, windowHeight){
closePopImg()
picTitle = windowTitle
imgWinName = &quot;popImg&quot; + imgCount++ //unique name for each pop-up window
popImg = window.open(picName, imgWinName,
&quot;toolbar=no,scrollbars=no,resizable=no,top=200,left=340,width=&quot;
+ (parseInt(windowWidth)+0) + &quot;,height=&quot;
+ (parseInt(windowHeight)+0))
}

function closePopImg(){ // close pop-up window if it is open
if (navigator.appName != &quot;Microsoft Internet Explorer&quot;
|| 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=&quot;closePopImg()&quot;>


<P>
<A HREF=&quot;JAVASCRIPT:eek:penPopImg(' 'Window title for large1 jpeg', '400', '300')&quot;><img src=&quot; alt=&quot;Name of Image1 if missing&quot; border=0></A>
<A HREF=&quot;JAVASCRIPT:eek:penPopImg(' 'Window title for large2 jpeg', '400', '300')&quot;><img src=&quot; alt=&quot;Name of Image2 if missing&quot; border=0></A>
</P>

</BODY>

</HTML>
 
What about adding something like this:

imgWinName = &quot;popImg&quot; + imgCount++ //unique name for each pop-up window
popImg = window.open(picName, imgWinName,
&quot;toolbar=no,scrollbars=no,resizable=no,top=200,left=340,width=&quot;
+ (parseInt(windowWidth)+0) + &quot;,height=&quot;
+ (parseInt(windowHeight)+0))

popImg.title = imgWinName;


would that work?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top