cuteangel1229
04-29-2003, 11:54 PM
do i change any of the code if there's two popups in a page, cause when i click on the two links, it came up as the same thing...
|
View Full Version : two popups on a page cuteangel1229 04-29-2003, 11:54 PM do i change any of the code if there's two popups in a page, cause when i click on the two links, it came up as the same thing... Lemon Squash 04-30-2003, 12:00 AM You need to give each popup a name. <script language="javascript"> <!-- function NAME() { window.open ("page.html","popup","width=400, height=200, location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=1, toolbar=0") } --> </script> <a href="java script:NAME()">click</a> amicus 05-02-2003, 12:39 AM i have slight changes to lemon squash's posting try this: function NAME( pageName ) { window.open (pageName,"popup","width=400, height=200, location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=1, toolbar=0"); } <a href="javascript:NAME( 'pageName.html' )">click</a> no code changes are necessary just pass in the url to the new page and you'll be just fine. MaGiCSuN 05-02-2003, 08:44 PM yes you do have to change NAME otherwise it won't work, 5 pop-ups can't have the same name, they won't work then. something like this: <script language="javascript"> <!-- function popup1() { window.open ("page1.html","popup1","width=400, height=200, location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=1, toolbar=0") } function popup2() { window.open ("page2.html","popup2","width=400, height=200, location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=1, toolbar=0") } --> </script> <a href="javascript:popup1()">click</a> <a href="javascript:popup2()">click</a> amicus 05-02-2003, 09:15 PM if you do it my way you'll only have one popup function. if in the future you want to start changing the window size and features you can pass in that information too. it's just another way of doing the same thing. i just think it's more clean, easier to maintain and a slightly faster page loads the way i suggest. it's more preference, if it's easier for you to understand to make seperate functions then that's the way to go. i just don't like duplicate code. the important thing is that it works :) |