Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

document.readyState = 'complete' giving an error

Posted on 2003-11-07
10
Medium Priority
?
1,659 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

877 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