Solved

document.readyState = 'complete' giving an error

Posted on 2003-11-07
10
1,597 Views
Last Modified: 2007-12-19
Hello guys,

I am trying to open a popup window from my page using window.open and in the child window, I am checking the document.readyState property to see if it is complete (checking to see if child completely loaded) and if it is, I want to reload the parent window since I update some values in the db from my child window.

Although the onLoad function does the same thing, when I tried using the onLoad function of the child window to see if it is loaded fully, the onLoad function is not getting triggered properly. This maybe because I am receiving a PDF stream to the child from the backend.

But, when I use the document.readyState property, I always get an "Access Denied" error in Javascript when the document is fully loaded.....I think I am almost there but this error is killing me....Is there any way I can get around this problem ??

If my question is not clear, please let me know and I will clarify..
0
Comment
Question by:prashanth9
  • 4
  • 3
  • 3
10 Comments
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9703589
what about using setTimeout onload and setting to reload the parent window after n seconds
0
 

Author Comment

by:prashanth9
ID: 9703658
I have tried using the setTimeOut function but I never know how long it takes for the child to get loaded - sometime it is quick and sometimes it takes longer...So, it doesnt work....

Here is the code that I have :
In the code below, _wPrint represents the child window.....
var _wPrint  = window.open('', 'some name);
--------------------------------------
function checkPage() {
  var loadedPage = false;
  if (_wPrint.document.readyState == "loading") {
      alert("Still WAITING...Not Loaded");
        setTimeout('checkPage()',100);
  } else {
                //This following function has the logic to reload the parent.....
                reload_parent();
}
0
 
LVL 25

Expert Comment

by:devic
ID: 9703689
try this:
==========================
function checkPage()
{
      var loadedPage = false;
      if (_wPrint.document.readyState == "complete")
      {
            //This following function has the logic to reload the parent.....
            reload_parent();
      }
      else
      {
            alert("Still WAITING...Not Loaded");
            setTimeout('checkPage()',3000);

      }
}
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 16

Expert Comment

by:jaysolomon
ID: 9703701
might try this

if (_wPrint.document.readyState != "interactive") {
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9703737
sorry clicked to soon i guess

if (_wPrint.document.readyState != "interactive") {
alert("Still WAITING...Not Loaded");
       setTimeout('checkPage()',100);
  } else {
                //This following function has the logic to reload the parent.....
                reload_parent();
}
0
 

Author Comment

by:prashanth9
ID: 9703775
Devic,

I tried the option you gave me earlier but it wouldnt work..I keep getting the alert as long as the page is not loaded but once it is loaded, or when the document.readyState is complete, I immediately get the "Access is Denied" error.....

Am I missing something ???

JaySolomon,

I tried your option too....Doesnt work...I get the same error....

0
 
LVL 25

Accepted Solution

by:
devic earned 100 total points
ID: 9703819
ok error is event too ;)

=-=======================
function checkPage()
{
      try
      {
            if (_wPrint.document.readyState != "complete")
            {
                  alert("Still WAITING...Not Loaded");
                  setTimeout('checkPage()',100);
      
            }
      }
      catch(e)
      {
            //This following function has the logic to reload the parent.....
            reload_parent();
      }
}
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9703902
if devics does not work then do this to test


in the pop up page

<script>
alert(document.readyState);
</script>

To see what it says when its loading
0
 

Author Comment

by:prashanth9
ID: 9704041
Thanks Devic..That was COOOOOOOOOOOOOOL.....I have been breaking my head with this problem for a day now...

It worked like a charm but I would have been much happier if I could do it the normal way instead of catching an exception and reloading the parent in the exception....

Btw, can you please tell me if this logic works in IE and netscape and what versions if possible....Thanks for the help !!!!
0
 
LVL 25

Expert Comment

by:devic
ID: 9704096
i don't support old browsers :)

i have only last versions, and can not help ;(

only info from the book:

Part of the try ... catch ...finally error-handling mechanism.

Availability:
ECMAScript edition – 3
JavaScript – 1.5
JScript – 5.0
Internet Explorer – 5.0
Netscape – 6.0

0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

831 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