controlling windows (focus and blur)

J

jpw

My objective is to open a window in the background (using body onload
of my initial page), giving it a chance to load. Upon an event from
the initial window (a button in my example), I want to bring the
"loading window" to the foreground. Consider the sample code below.
The second window (the one I'm loading in the background) will not
come to focus (or, it won't stay in focus).

Thanks for your help:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<SCRIPT LANGUAGE="JavaScript">

function jpw(x) {

if (x==1) {
me.blur;
myWindowHandle = window.open("","map")
myWindowHandle.focus()
}
else
{

myWindowHandle = window.open("http://www.exeter.edu/map/link/
2005StudentTour.html","map");
myWindowHandle.blur()

}
}



</SCRIPT>

<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body onload="jpw('2');">
<p>Primary Window</p>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="">
<input type="submit" name="Submit" value="Submit"
onclick="window.open('','map').focus(); />
</form>
<p>&nbsp;</p>
</body>
</html>
 
D

David Mark

My objective is to open a window in the background (using body onload
of my initial page), giving it a chance to load. Upon an event from
the initial window (a button in my example), I want to bring the
"loading window" to the foreground. Consider the sample code below.
The second window (the one I'm loading in the background) will not
come to focus (or, it won't stay in focus).

Thanks for your help:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<SCRIPT LANGUAGE="JavaScript">

function jpw(x) {

if (x==1) {
me.blur;
myWindowHandle = window.open("","map")
myWindowHandle.focus()
}
else
{

myWindowHandle = window.open("http://www.exeter.edu/map/link/
2005StudentTour.html","map");
myWindowHandle.blur()

}

}

</SCRIPT>

<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body onload="jpw('2');">
<p>Primary Window</p>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="">
<input type="submit" name="Submit" value="Submit"
onclick="window.open('','map').focus(); />
</form>
<p>&nbsp;</p>
</body>
</html>

This is pretty convoluted. Why don't you just open the child window
when the button is clicked? And why are you using a form for this
anyway? A link would seem more appropriate. I believe the group FAQ
has a good window.open example that will do what you want, whether you
open the window in advance or not.
 
J

jpw

This is pretty convoluted. Why don't you just open the child window
when the button is clicked? And why are you using a form for this
anyway? A link would seem more appropriate. I believe the group FAQ
has a good window.open example that will do what you want, whether you
open the window in advance or not.- Hide quoted text -

- Show quoted text -

Thanks for the reply. This is simply a shell to secure functinality.
The live implementation is a page that *has* a form (thus, the form in
the example). I can try a link, but not sure why the button wouldn't
function. I'll look for the sample you mention, but won't it just
be: window.open("","map")?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top