This topic is in the Website Design discussion forum.  (rss)


Multiple javascript popups




Topic started on 4-2-2005 @ 01:06 AM by Simulacra


I'm using the following popup _javascript in order to control the size of a window on a link of my website. Here is the following code:




SCRIPT LANGUAGE="JavaScript">

!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=680,height=600,left = 191,top = 134');");
}
// End -->
/script>



Now I want to have another pop-up window on my site using a different widthxlength. Would I have to place another Javascript on my site or can I modify this to include both of the links (and any others that may arise that require different widthxlength)?



reply to this post:   copyright & usage 


reply posted on 5-2-2005 @ 12:50 PM by dreamlandmafia


Junk that code...and using something simpler.



< script "JavaScript" type="text/_javascript">
function popup()
{
window.open("http://URL HERE","ID","width=680,height=600,toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0");
}
< /script>



(without the space in the opening and closing tags, and the _ in JS. That cant be helped when posting)

Then when you have a link that you want to execute that...just have < a href="#" onclick="popup();">TEXT< /a>.

Lets say you want 2 different ones with different widths and heights...then the above would be something like this...



< script "JavaScript" type="text/_javascript">
function popup()
{
window.open("http://URL HERE","ID","width=680,height=600,toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0");
}

function popup2()
{
window.open("http://URL HERE","ID","width=XXX,height=XXX,toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0");
}
< /script>



Then you just use the link code that I showed you, but substitue popup() for the function name of whichever you want.

Hope that makes sense.

[edit on 2-5-2005 by dreamlandmafia]



reply to this post:   copyright & usage 


reply posted on 5-2-2005 @ 12:58 PM by junglejake


Sim, all you would have to do is replace the width and height with a variable, and have the link that calls the JS pass a the value of those variables when it calls the JS function. If you want more dtail say so, but also pop me a U2U as I may not find this thread again in the future.



reply to this post:   copyright & usage 


reply posted on 7-2-2005 @ 02:11 AM by Simulacra


Just wanted to thanks guys. I figured out how to implement multi-popups on the site. Continued thanks goes out for answering my Web questions.



reply to this post:   copyright & usage 


reply posted on 13-9-2005 @ 10:06 AM by 12m8keall2c


See that you got it worked out, but here's another option.

IN HEAD:


<script "_javascript" type="text/_javascript">
<!--
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*(( screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,men ubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);
if(win.focus){win.focus();}}
// -->
</script>


IN BODY:

Unlimited links using only


<a href=_javascript:NewWindow('whatever.html','mywin','320','240','yes','center')>


By simply replacing the page,width, height, etc. there's no limit to the number of popup links.

The best part is it reduces redundant code through your page, and stiil gives you direct control over size and location of all popups.



[edit on 9/13/2005 by 12m8keall2c]

[edit on 9/13/2005 by 12m8keall2c]



reply to this post:   copyright & usage 










Top Topics Right Now:



Active Topics Right Now:



ATS MIX Podcasts:











Newest Topics:


























ATS Server: www4.theabovenetwork.com
Powered by AboveTop:Board v2.3
Header data processed in 0.004 seconds
Page processed in 0.122 seconds
6 total database queries (1)









The Below Top Secret General Discussion Web site is a wholly owned social content community of The Above Network, LLC.

Documents



thread
Forums Directory