dcsimg
www.webdeveloper.com
Results 1 to 7 of 7

Thread: Detect when page has completed loading without JQuery? Is this possible?

  1. #1
    Join Date
    May 2010
    Posts
    24

    Detect when page has completed loading without JQuery? Is this possible?

    Thank you.

    window.onload does not quite seem to do the trick.

    My only other idea is to do:
    setInterval(myfunction,1000)

    where myfunction goes through DOM tree and detects any changes (well at least element additions - new elements with unknown id's).

    What do you guys think?

    Misha

    p.s. I'm reassigning IDs anyway so should be doable...

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    If you believe you can accomplish your goal using jQuery, why not use it?

  3. #3
    Join Date
    May 2010
    Posts
    24
    Quote Originally Posted by Fang View Post
    If you believe you can accomplish your goal using jQuery, why not use it?
    Good point. Several questions for you:
    1) I am running Javascript on the client (browser) side rather than from the Web site (analogous to the javascript: command in FireFox). Can I use jQuery from the client side? If so, how?
    2) If I use jQuery, does the document.load _ensure_ that the page has completed loading? In other words - if I want to read the DOM structure of the document _once_, can I safely do so after document.load in jQuery, or could there still be changes (_not_ caused by user interaction) that occur as a result?

    Thank you
    Misha

    p.s. Here is my simple idea:
    * look at document.getElementsByTagName('*').length every 2 seconds (?)
    * if it has not changed - we are done. otherwise, wait again

    What do you think?

    Thank you!

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    1) Include the jQuery library in the document.

    2) That would depend on what you are doing.

  5. #5
    Join Date
    May 2010
    Posts
    24
    Ok... but I can't control the document. So is (1) still possible? Thank you!

    Misha

  6. #6
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    but I can't control the document
    So it's not your site? Please explain what your goal is; we then may be able to help you better.

  7. #7
    Join Date
    May 2010
    Posts
    24
    I am working on a Web Automation Framework
    http://www.mkosh.com
    in the spirit of WebDriver
    http://code.google.com/p/selenium/wiki/GettingStarted
    using the SWT Browser object
    http://www.eclipse.org/articles/Arti...t/browser.html

    In other words:
    i) I have a Java application (on the user's computer)
    ii) I am able to do two things from this application:
    a) go to some URL
    b) execute Javascript code in the browser object
    iii) I would like to somehow know when the page has finished loading

    My only idea is to:
    a) execute: return document.findElementsByTagName('*').length and record value
    b) wait two seconds
    c) execute: return document.findElementsByTagName('*').length and record value
    d) If the value from (c) is different from previous value, goto (b). Otherwise, page has finished loading...

    Any other ideas?

    Thank you
    Misha

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles