Window status works in FF, but not IE...why?
I have a project where I need to check to see if a pop-up window I've created is still open. I've pieced together some code, but it only works correctly in FF, but not IE. JavaScript is not my forte and I'm at a loss as to what the issue is.
The code below works fine as is, but if I change this line:
<a href="#" onclick="winOpen('','testSite','295','300','no');r eturn false;">Open</a><br>
to this:
<a href="#" onclick="winOpen('http://www.msn.com','testSite','295','300','no');return false;">Open</a><br>
it doesn't work in IE...it comes back saying the window doesn't exist even if it does.
Any ideas?
Thanks!
Chris
<html>
<head>
<title>Window Test</title>
<script language="JavaScript" type="text/javascript">
<!--
function winOpen(url, myname, w, h, scroll)
{
var winl = (screen.width - w) / 2;
var wint = ((screen.height - h) / 2)-20;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl +',scrollbars='+scroll+',toolbar=0, status=0, resizable=0,menubar=0'
eval(myname+" = window.open(url, myname, winprops)");
if (parseInt(navigator.appVersion) >= 4 || parseInt(ie.appVersion) >= 4) { eval(myname+".window.focus()"); }
}
function winCheck(winSite)
{
try{
if(eval("window."+winSite+".document"))
{
alert("Window \""+winSite+"\" open");
}
else
{
alert("Window \""+winSite+"\" not found");
}
}
catch(e){
alert("Window \""+winSite+"\" not found");
}
}
function winClose(winSite)
{
try{
if(eval("window.testSite.document"))
{
window.testSite.close()
}
else
{
alert("Window \""+winSite+"\" not found");
}
}
catch(e){
alert("Window \""+winSite+"\" not found");
}
}
//-->
</script>
</head>
<body>
<h1>Window Test</h1>
<a href="#" onclick="winOpen('','testSite','600','400','no');r eturn false;">Open</a><br>
<a href="#" onclick="winCheck('testSite');">Check</a><br>
<a href="#" onclick="winClose('testSite');">Close</a><br>
</body>
</html>
|