...

View Full Version : Making a popup window show different .jpg files



DonAtlanta
07-25-2002, 09:59 PM
I want to have a dozen links on my web page
such that clicking each link will pop up a different jpg file in a small window.

I found the code below to create a popup window.

Clicking link "Kevin" should pop up file kevinw.jpg (actually, that works)

Clicking link "Flower" should pop up file
photo19.jpg (that doesn't)

How do I move the variable "popurl" out of the
function so that I can assign it different
values in different places on the web page?

(Obviously variables in java don't work
like variables in BASIC.)

===========================

function openpopup(){
var popurl="kevinw.jpg"
winpops=window.open(popurl,"","width=400,height=338,")
}

</script>

<a href="javascript:openpopup()">Kevin</a>

var popurl="photo19.jpg"
<a href="javascript:openpopup()">Flower</a>

Hawk
07-25-2002, 10:48 PM
I am not sure what you are trying to do but here is something I found on this forum a while back. I altered the code a bit to my need. It is quite simple to understand.



<head>
<script type="text/javascript">
if (document.images)
{
adImages = new Array("./Dru01.jpg", "./Dru02.jpg", "./Dru03.jpg", "./Dru04.jpg", "./Dru05.jpg");
adURLs = new Array("www.yahoo.com", "www.geocities.com", "www.yahoo.com", "www.yahoo.com", "www.yahoo.com");
int_Counter = 0;
}

function f_cycleAds()
{
if (document.images)
{
if (document.imgBox.complete)
{
if (++int_Counter == adImages.length)
{
int_Counter = 0;
}

document.imgBox.src = adImages[int_Counter];
window.status=int_Counter + ' ' + adImages[int_Counter] + ' ' + adURLs[int_Counter];
}
}

// change picture every 2 seconds
setTimeout("f_cycleAds()", 2000);
}

function f_Goto()
{
document.location.href = "http://" + adURLs[int_Counter];
}
</script>
</head>
<body onload="f_cycleAds()" text="blue">
<a href="javascript:f_Goto()">
<img name="imgBox" src="./Dru01.jpg" border="0" alt="Our sponsors">
</a>
</body>

boywonder
07-25-2002, 10:48 PM
<script>
function openpopup(popurl){
winpops=window.open(popurl,"","width=400,height=338,")
}
</script>
<a href="javascript:openpopup('kevinw.jpg')">Kevin</a>
<a href="javascript:openpopup('photo19.jpg')">Flower</a>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum