SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    PHP Otaku Gibb's Avatar
    Join Date
    Jul 2004
    Location
    Texas
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Run script after page load complete?

    I've searched around for a while, but I can't seem to find the syntax to do this, assuming there is one.

    I have a page that allows users to print out maps generated by mapquest. If the user clicks the "Print" button (the one on the page) before the page has finished loading the maps, the print-outs will have errors appearing on them.

    I've been talking with MapQuest about the issue, and I don't think it's anything they can fix on their end.

    What I would like to do is create a script that unhides the "PRINT" button only after the page has finished loading.

    Something like this:
    Code:
    if (pageloadcomplete) {
    //unhide print button
    }
    I assume there's a way to do that in Javascript, but i can't find the syntax anywhere.

  2. #2
    SitePoint Addict telos's Avatar
    Join Date
    Mar 2005
    Location
    192.168.2.34
    Posts
    279
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could use the onload="" attribute in the body tag, I believe.

  3. #3
    PHP Otaku Gibb's Avatar
    Join Date
    Jul 2004
    Location
    Texas
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by telos View Post
    you could use the onload="" attribute in the body tag, I believe.
    The "onload" function runs javascript before the content section loads, as far as I know. I need a function that runs ONLY after the entire content page has finished loading. For example if I have a page with 50 images on it. I want to only run a javascript function after all 50 images are loaded.

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Gibb View Post
    The "onload" function runs javascript before the content section loads, as far as I know. I need a function that runs ONLY after the entire content page has finished loading. For example if I have a page with 50 images on it. I want to only run a javascript function after all 50 images are loaded.
    The body onload event only triggers when the page has finished being loaded, which includes all of the images have completed downloading.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

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