Trigger a function after the page is fully loaded

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bnashenas1984
    Contributor
    • Sep 2007
    • 257

    Trigger a function after the page is fully loaded

    [MOD: Moved from the PHP forum. --pbmods]

    Hi everyone
    Actually I'm not sure if I have to post this question in PHP forum.
    I have a page (download page) which contains a link but I want the link to be invisible until the page is fully loaded.
    The reason is that if the link apears at the begining then the user will click on it to download the file and then close the window before banners are loaded and it would not be counted as a page view on google adsense.
    So I need to have an invisible link which apears when the page is fully loaded.
    I'v seen this before on other websites but don't know how to do it. I think I'm gonna need a JAVA function or something.

    Any suggestions will be appreciated

    regards
  • joedeene
    Contributor
    • Jul 2008
    • 579

    #2
    What about something like <body onload="myfunct ion()"> ? And give your function some kind of action to show the link?

    joedeene

    Comment

    • bnashenas1984
      Contributor
      • Sep 2007
      • 257

      #3
      Thanks joedeene
      You solved my problem. I wasn't sure if ONLOAD runs the function when the HTML is loaded or after loading the whole page.
      It seems to work fine now.
      Here is what I used:

      Code:
      <body onload="objectid.style.display='block'">
      <a id="objectid" href="www.example.com" style="display:none">something</a>
      </body>
      Thanks again

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        That won't work in most browsers, at least in strict mode.

        Use document.getEle mentById() to access an element. The ID doesn't make it accessible in the global namespace.

        Comment

        • bnashenas1984
          Contributor
          • Sep 2007
          • 257

          #5
          Originally posted by acoder
          That won't work in most browsers, at least in strict mode.

          Use document.getEle mentById() to access an element. The ID doesn't make it accessible in the global namespace.
          Thanks for the help acoder
          I really appreciate it :)

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            No problem, you're welcome :)

            Comment

            Working...