Solved

How Do I check if document is open?

Posted on 2004-09-15
7
166 Views
Last Modified: 2010-04-06
I want to run the following code but only if the document has not been closed.

parent.opener.document.forms[0].submit();

(if its not open the code crashes)


thanks

Steven Copley
0
Comment
Question by:stevencopley
7 Comments
 
LVL 33

Expert Comment

by:sajuks
Comment Utility
// try this
if ( parent.opener)
{
    parent.opener.document.forms[0].submit();
}
0
 

Author Comment

by:stevencopley
Comment Utility
sorry but it didn't work..

      if(parent.opener){
            alert(1234);
            parent.opener.document.forms[0].submit();
      }


I get the alert come up although the opener is not there any more.

0
 
LVL 33

Expert Comment

by:sajuks
Comment Utility
Can you post what you are trying to do . The parent and child code pages
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 33

Expert Comment

by:sajuks
Comment Utility
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>
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
Try:

if (parent.opener && !parent.opener.closed)
0
 
LVL 3

Expert Comment

by:xakem
Comment Utility
if (window.opener)
{
     //your code
     window.opener.document.forms[0].submit();
     //your code
}
0
 
LVL 3

Accepted Solution

by:
xakem earned 500 total points
Comment Utility
sorry the right and the smallest one :) :
if (opener && !opener.closed)
{
     //your code
     opener.document.forms[0].submit();
     //your code
}
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now