Welcome to WebmasterWorld Guest from 23.20.6.20

Forum Moderators: mack

Message Too Old, No Replies

javascript - popup windows

multiple popups on one page

     
7:23 pm on Mar 3, 2003 (gmt 0)

New User

10+ Year Member

joined:Feb 26, 2003
posts:29
votes: 0


I know very little about javascript, but really 'need' to use popup windows on a site I'm designing to save space. I copied some code from a jscript tutorial site, and it worked fine when there was only one pop up on the page. But now that I've created several popups for the page, only one of them gets displayed for all the buttons on the page.

I think there is a variable that is being set in the loadwindow function that is affecting this, but don't know much beyond that.

here's what the code snippet looks like:

<script>
function loadwindow(){
window.open("Pop_up1.html","","width=400,height=350,status=1")
}
</script>
<form><input type="button" onClick="loadwindow()" value="See Description"></form>

<<new row, cell, etc.>>

<script>
function loadwindow(){
window.open("Pop_up2.html","","width=400,height=350,status=1")
}
</script>
<form><input type="button" onClick="loadwindow()" value="See Description"></form>

The problem is that its loading Pop_up2.html for both buttons.

I know I need to actually learn this stuff and I'm trying the easy way out, but just this once please help! :)

7:30 pm on Mar 3, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Jan 7, 2003
posts:1230
votes: 0


hi lachtzu,

in your code, the main mistake is to define the function loadwindow() two times. if you locate the second definition of the function, just add a '2' to the functions name (it will then be loadwindow2()), and do so in the second button which then will open the 2nd popup window.

7:32 pm on Mar 3, 2003 (gmt 0)

Administrator

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
posts:15755
votes: 0


maybe pass the pagename to the function

function loadwindow(page){
window.open(page,"popup","width=400,height=350,status=1")
}

<input type="button" onClick="loadwindow('Pop_up1.html')" value="See Description">
<input type="button" onClick="loadwindow('Pop_up2.html')" value="See Description">

8:04 pm on Mar 3, 2003 (gmt 0)

New User

10+ Year Member

joined:Feb 26, 2003
posts:29
votes: 0


and the winner is...Hakre! I'm sure both work - in this case naming the functions separately was very easy and quick. Thanks