Link to home
Start Free TrialLog in
Avatar of andy7789
andy7789

asked on

Opening a pop-up behind the main window

Hi X-perts,

I need to achieve the following functionality with an external pop-up window:

1) onLoading the page should open an external window behind the currently opened browser window. How can I keep the pop-up behind? Probably, keeping the main window onFocus? How?
2) closing the main window (not pop-up) should trigger a jscript function in the opened pop-up.

Please, advise.

Thank you

-A-
ASKER CERTIFIED SOLUTION
Avatar of third
third
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andy7789
andy7789

ASKER

Exactly what I needed! Thank you
Third,

It was too early to celebrate. When I increase the pop up size to something like 500x500, it opens behind the main window and pops on the top. What is wrong? I cannot understand how its size can change its action

Please, take a look
Note that increasing the popup window does not work in FF  - it seems that ie is OK
tested it but it works well in FF. please post your code.
I have tested it with your code and increasing the popup to 500x500 makes it open below the main window and next brings it on the top. My currect code is almost the same as yours:

main.ntml:
====================
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Main page</title>
<script>
  function popup(){
    newwin = window.open('popup.html','newwin','width=400,height=500');
    newwin.blur();
  }
  function init(){
  newwin.focus();
  newwin.startMovie();
  }
</script>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" onLoad="popup()" onUnload="init();">
</body>
</html>

popup.html:
===============
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script type="text/javascript" src="floatingLayer4.js"></script>
<title>Popup test</title>
<script>
  function callme(){
    alert('test');
  }
  function startMovie() {
  showThis('layer1');
  showMovie('test.swf',50000);
  showThis('close');
  window.focus();
  }
</script>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<div id="layer1" style="position:absolute; left:50px; width:250px; height:10px; visibility:hidden">
</div>
<div id="close" style="position:absolute; left:100px; width:40px; height:18px; visibility:hidden" onClick="closeMovie(); hideThis('close');">
<img src="CLOSE_0.gif">
</div>

</body>
</html>

I have tested it on simple alert functions and it does not work for FF. Probably, I have to add something like this to the popup.html code:

function refresh() {
if(window.blur) window.focus();
setTimeout("refresh()", 50);
}

Another option would be to add window.focus() to the body tag <body onBlur="window.focus()">. How can I add it AFTER the popup event is triggered?

Pls, advise.

Thanks
A