Marketing_Insists
asked on
bring popups to front and refresh
when a user requests a pop-up via link, is their a way to make sure the pop-up appears on top of the page
instead of behind it if the previous popupof the same name lost focus?
The user requested links open up precisely sized images, sole swf's or external websites in the center
of the page. If they skip manually closing the first popup and request another popup on the parent page,
the old popup loses focus and loads the a new pop-up behind the parent page, hiding it from the user.
Not only that but the next popup that opens has the same dimmensions as the last pop-up, even though
the new popup's size is defined otherwise (hence my desire for the popup to refresh)
Because the pop-up's aren’t always HTML, I'm hoping that the code to bring the pop-up to the front is
contained in the parent HTML page.
(I could just load a new pop-up each time, but that would obviously clutter things up and peeve the user.)
here's what I have:
<html><head>
<script language="javascript" type="text/javascript">
<!--
var win=null;
function NewWindow(mypage,myname,w, h,scroll,p os){
if(pos=="random"){LeftPosi tion=(scre en.width)? Math.floor (Math.rand om()*(scre en.width-w )):100;Top Position=( screen.hei ght)?Math. floor(Math .random()* ((screen.h eight-h)-7 5)):100;}
if(pos=="center"){LeftPosi tion=(scre en.width)? (screen.wi dth-w)/2:1 00;TopPosi tion=(scre en.height) ?(screen.h eight-h)/2 :100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0; TopPositio n=20}
settings='width='+w+',heig ht='+h+',t op='+TopPo sition+',l eft='+Left Position+' ,scrollbar s='+scroll +',locatio n=no,direc tories=no, status=no, menubar=no ,toolbar=n o,resizabl e=no';
win=window.open(mypage,myn ame,settin gs);}
// -->
</script></head>
<body><br><br>
First link load's without a problem<br>
<a href="https://www.experts-exchange.com/images/indexLogo.gif" onclick="NewWindow(this.hr ef,'same-p opup','350 ','25','no ','center' );return false" onfocus="this.blur()">link to picture</a>
<br><br>
...but if you click on the next link without closing the previous one manually
(with the close 'X' in the upper right corner of the browser), the popup loses focus
and loads the next popup behind the parent page<br>
<a href="http://oddtodd.com/laidoff2.swf" onclick="NewWindow(this.hr ef,'same-p opup','300 ','200','n o','center ');return false" onfocus="this.blur()">Link to flash</a>
<br><br>
Not only that but the next popup that opens has the same dimmensions as the last
pop-up, even though the new popup's size is defined otherwise<br>
<a href="http://google.com" onclick="NewWindow(this.hr ef,'same-p opup','500 ','400','n o','center ');return false" onfocus="this.blur()">Link to web page</a>
<br><br><br>
Currently, each page must be closed manually so that the next one will load correctly
</body></html>
instead of behind it if the previous popupof the same name lost focus?
The user requested links open up precisely sized images, sole swf's or external websites in the center
of the page. If they skip manually closing the first popup and request another popup on the parent page,
the old popup loses focus and loads the a new pop-up behind the parent page, hiding it from the user.
Not only that but the next popup that opens has the same dimmensions as the last pop-up, even though
the new popup's size is defined otherwise (hence my desire for the popup to refresh)
Because the pop-up's aren’t always HTML, I'm hoping that the code to bring the pop-up to the front is
contained in the parent HTML page.
(I could just load a new pop-up each time, but that would obviously clutter things up and peeve the user.)
here's what I have:
<html><head>
<script language="javascript" type="text/javascript">
<!--
var win=null;
function NewWindow(mypage,myname,w,
if(pos=="random"){LeftPosi
if(pos=="center"){LeftPosi
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;
settings='width='+w+',heig
win=window.open(mypage,myn
// -->
</script></head>
<body><br><br>
First link load's without a problem<br>
<a href="https://www.experts-exchange.com/images/indexLogo.gif" onclick="NewWindow(this.hr
<br><br>
...but if you click on the next link without closing the previous one manually
(with the close 'X' in the upper right corner of the browser), the popup loses focus
and loads the next popup behind the parent page<br>
<a href="http://oddtodd.com/laidoff2.swf" onclick="NewWindow(this.hr
<br><br>
Not only that but the next popup that opens has the same dimmensions as the last
pop-up, even though the new popup's size is defined otherwise<br>
<a href="http://google.com" onclick="NewWindow(this.hr
<br><br><br>
Currently, each page must be closed manually so that the next one will load correctly
</body></html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ooops, just noticed that the pevious code won't work in IE
tis again;
<html>
<head>
<script language="javascript" type="text/javascript">
var win=null;
function NewWindow(mypage,myname,w, h,scroll,p os){
if(pos=="random"){LeftPosi tion=(scre en.width)? Math.floor (Math.rand om()*(scre en.width-w )):100;Top Position=( screen.hei ght)?Math. floor(Math .random()* ((screen.h eight-h)-7 5)):100;}
if(pos=="center"){LeftPosi tion=(scre en.width)? (screen.wi dth-w)/2:1 00;TopPosi tion=(scre en.height) ?(screen.h eight-h)/2 :100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0; TopPositio n=20}
settings='width='+w+',heig ht='+h+',t op='+TopPo sition+',l eft='+Left Position+' ,scrollbar s='+scroll +',locatio n=no,direc tories=no, status=no, menubar=no ,toolbar=n o,resizabl e=no';
win=window.open(mypage,myn ame,settin gs);}
</script>
</head>
<body><br><br>
<a href="https://www.experts-exchange.com/images/indexLogo.gif" onclick="NewWindow(this.hr ef,'same', '350','25' ,'no','cen ter');retu rn false" onfocus="this.blur()">Link -to-pictur e</a>
<br><br>
<a href="http://oddtodd.com/laidoff2.swf" onclick="NewWindow(this.hr ef,'same', '300','200 ','no','ce nter');ret urn false" onfocus="this.blur()">Link -to-flash< /a>
<br><br>
<a href="http://google.com" onclick="NewWindow(this.hr ef,'same', '500','400 ','no','ce nter');ret urn false" onfocus="this.blur()">link -to-html</ a>
</body></html>
tis again;
<html>
<head>
<script language="javascript" type="text/javascript">
var win=null;
function NewWindow(mypage,myname,w,
if(pos=="random"){LeftPosi
if(pos=="center"){LeftPosi
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;
settings='width='+w+',heig
win=window.open(mypage,myn
</script>
</head>
<body><br><br>
<a href="https://www.experts-exchange.com/images/indexLogo.gif" onclick="NewWindow(this.hr
<br><br>
<a href="http://oddtodd.com/laidoff2.swf" onclick="NewWindow(this.hr
<br><br>
<a href="http://google.com" onclick="NewWindow(this.hr
</body></html>
Right here where you open:
win=window.open(mypage,myn ame,settin gs);}
Just change it to:
win=window.open(mypage,myn ame,settin gs);win.fo cus();}
And it will bring it to the top in order to bring focus to it.
Cd&
win=window.open(mypage,myn
Just change it to:
win=window.open(mypage,myn
And it will bring it to the top in order to bring focus to it.
Cd&
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad we could help. Thanks for the A. :^)
Cd&
Cd&
ASKER
Thanks!
Both of you had part of the answer,
You guys in cahoots? ;-)
Both of you had part of the answer,
You guys in cahoots? ;-)
;)
btw, i noticed, if i open the window with location ".sfw", i can not close this window at once.
here another version:
================
<html>
<head>
<script language="javascript" type="text/javascript">
var win=null;
function NewWindow(mypage,myname,w, h,myscroll ,pos)
{
if(win)win.close();
if(pos=="random"){LeftPosi tion=(scre en.width)? Math.floor (Math.rand om()*(scre en.width-w )):100;Top Position=( screen.hei ght)?Math. floor(Math .random()* ((screen.h eight-h)-7 5)):100;}
if(pos=="center"){LeftPosi tion=(scre en.width)? (screen.wi dth-w)/2:1 00;TopPosi tion=(scre en.height) ?(screen.h eight-h)/2 :100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0; TopPositio n=20}
var settings='width='+w+',heig ht='+h+',t op='+TopPo sition+',l eft='+Left Position+' ,myscrollb ars='+mysc roll+',loc ation=no,d irectories =no,status =no,menuba r=no,toolb ar=no,resi zable=no';
win=window.open("about:bla nk",myname ,settings) ;
win.document.write("<html> <body topmargin=0 leftmargin=0 marginwidth=0 marginheight=0><body>")
var ext=mypage.substr(mypage.l astIndexOf ('.')+1)
if(ext.match(/gif|jpg|png/ ))win.docu ment.write ("<img src="+mypage+">");
else if(ext=="swf")win.document .write("<e mbed src="+mypage+" width=100% height=100% type=application/x-shockwa ve-flash>< /embed>");
else win.document.write("<ifram e src="+mypage+" width=100% height=100% width=100% height=100% frameborder=0></iframe>");
win.document.write("</body ></html>")
win.focus();
}
</script>
</head>
<body><br><br>
<a href="https://www.experts-exchange.com/images/indexLogo.gif" onclick="NewWindow(this.hr ef,'same', '350','25' ,'no','cen ter');retu rn false">Link-to-picture</a>
<br><br>
<a href="http://oddtodd.com/laidoff2.swf" onclick="NewWindow(this.hr ef,'same', '300','200 ','no','ce nter');ret urn false">Link-to-flash</a>
<br><br>
<a href="http://google.com" onclick="NewWindow(this.hr ef,'same', '500','400 ','no','ce nter');ret urn false">link-to-html</a>
</body></html>
btw, i noticed, if i open the window with location ".sfw", i can not close this window at once.
here another version:
================
<html>
<head>
<script language="javascript" type="text/javascript">
var win=null;
function NewWindow(mypage,myname,w,
{
if(win)win.close();
if(pos=="random"){LeftPosi
if(pos=="center"){LeftPosi
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;
var settings='width='+w+',heig
win=window.open("about:bla
win.document.write("<html>
var ext=mypage.substr(mypage.l
if(ext.match(/gif|jpg|png/
else if(ext=="swf")win.document
else win.document.write("<ifram
win.document.write("</body
win.focus();
}
</script>
</head>
<body><br><br>
<a href="https://www.experts-exchange.com/images/indexLogo.gif" onclick="NewWindow(this.hr
<br><br>
<a href="http://oddtodd.com/laidoff2.swf" onclick="NewWindow(this.hr
<br><br>
<a href="http://google.com" onclick="NewWindow(this.hr
</body></html>
ASKER
onfocus="this.blur();win.f
?