Help - Search - Members - Calendar
Full Version: pop up windows
HTMLHelp Forums > Programming > Client-side Scripting
Deacon
Hello,
I was wondering could anyone help me, I have a popup window appearing once an initial page has loaded. However this pop up appears behind the main window. I have used a focus() method but it doesnt seem to work. If any one can help me it would be very much appreciated....

Here is my code for the main window ---------------------------------------------

<html>
<head>
<script language="JavaScript" type="text/JavaScript">
function new_win(new_page, win_width, win_height) {
var posLeft= ((screen.width/2)-(win_width/2));
var posTop= ((screen.height/2)-(win_height/2));
var winID= window.open(new_page, 'newWin', 'toolbar=no, location=no, scrollbars=no, resizable=no, width=' + win_width + ', height=' + win_height + ', left=' + posLeft + ', top= ' + posTop);
winID.focus();
}

</script>
</head>

<body onLoad="new_win('flash.html', '800', '600');" winID.focus();>
</body>
</html>

Here is the code for the pop up ---------------------------------------------------

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
</head>
<body >
<table align="center" width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td>
<table align="center" width="800" height="100%" border="0" cellspacing="0" cellpadding="0" bordercolor="#999999" >
<tr>
<td height="100%">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="800" height="600">
<param name="movie" value="flash/finished_website.swf" />
<param name="quality" value="high" />
<embed src="flash/finished_website.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="800" height="600"></embed>
</object>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Frederiek
It works for me (Safari 3/Mac).

Try changing:
<body onLoad="new_win('flash.html', '800', '600');" winID.focus();>

to:
<body onLoad="new_win('flash.html', '800', '600'); winID.focus();">

You then also shouldn't be needing the winID.focus(); in the script.

Christian J
Works in my Windows browsers too (after disabling their popup blockers).
Deacon
No, still having problems...in explorer the pop up is still appearing behind the main window...
Christian J
In my IE7 the popup doesn't get focus when I right-click the HTML file on my desktop and choose "open with IE", but when I paste the URL into the address bar the popup does get focus.
Deacon
does this mean that once the site is online the popup will get focused???
Deacon
Success, had a look on goolge and found some script that does the same thing....Thank you to those who offered help
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2014 Invision Power Services, Inc.