homepage Welcome to WebmasterWorld Guest from 54.167.10.244
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

    
javascript - popup windows
multiple popups on one page
lachtzu




msg:958600
 7:23 pm on Mar 3, 2003 (gmt 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! :)

 

hakre




msg:958601
 7:30 pm on Mar 3, 2003 (gmt 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.

jatar_k




msg:958602
 7:32 pm on Mar 3, 2003 (gmt 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">

lachtzu




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / New To Web Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved