It looks like you're using an Ad Blocker.

Please white-list or disable AboveTopSecret.com in your ad-blocking tool.

Thank you.

 

Some features of ATS will be disabled while you continue to use an ad-blocker.

 

Multiple javascript popups

page: 1
0

log in

join
share:

posted on Feb, 4 2005 @ 01:06 AM
link   
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();
"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)?



posted on Feb, 5 2005 @ 12:50 PM
link   
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]



posted on Feb, 5 2005 @ 12:58 PM
link   
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.



posted on Feb, 7 2005 @ 02:11 AM
link   
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.



posted on Sep, 13 2005 @ 10:06 AM
link   
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]



new topics

top topics
 
0

log in

join