stevencopley
asked on
How Do I check if document is open?
I want to run the following code but only if the document has not been closed.
parent.opener.document.for ms[0].subm it();
(if its not open the code crashes)
thanks
Steven Copley
parent.opener.document.for
(if its not open the code crashes)
thanks
Steven Copley
ASKER
sorry but it didn't work..
if(parent.opener){
alert(1234);
parent.opener.document.for ms[0].subm it();
}
I get the alert come up although the opener is not there any more.
if(parent.opener){
alert(1234);
parent.opener.document.for
}
I get the alert come up although the opener is not there any more.
Can you post what you are trying to do . The parent and child code pages
in your parent window declare a variable like this :
var myvar = true
in your popup window
<html>
<head>
<script language="javascript">
<!--
function checkparent() {
if (opener.myvar) alert("yes")
else alert("no")
}
//-->
</script>
</head>
<body>
<form>
<input type="button" value="Valid" onclick="checkparent">
</form>
</body>
</html>
var myvar = true
in your popup window
<html>
<head>
<script language="javascript">
<!--
function checkparent() {
if (opener.myvar) alert("yes")
else alert("no")
}
//-->
</script>
</head>
<body>
<form>
<input type="button" value="Valid" onclick="checkparent">
</form>
</body>
</html>
Try:
if (parent.opener && !parent.opener.closed)
if (parent.opener && !parent.opener.closed)
if (window.opener)
{
//your code
window.opener.document.for ms[0].subm it();
//your code
}
{
//your code
window.opener.document.for
//your code
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if ( parent.opener)
{
parent.opener.document.for
}