www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: Excute Function on page Load

  1. #1
    Join Date
    Oct 2004
    Posts
    66

    Question Excute Function on page Load

    This is a simple question but how would I excute a fucntion on page load without a event handler.

  2. #2
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Code:
    <script type="text/javascript"><!--
    onload = function(){
     // ...
    }
    //--></script>

  3. #3
    Join Date
    Oct 2004
    Posts
    66
    That was fast. I mean really fast mere seconds.

  4. #4
    Join Date
    Oct 2004
    Posts
    66
    Ok i'm using setTimeout() to update page every 1 second. Using onload = function() {}

    It's not updating.

    Any idea why?

  5. #5
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Update page every one second?

    Code:
    function update(){
     // ...
    }
    
    onload = function(){setTimeout('update()', 1000)};

  6. #6
    Join Date
    Oct 2004
    Posts
    66
    What about?

    PHP Code:
    window.onload "functionName()"
    Sorry just curious. I tryed and it didn't work.

  7. #7
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    You can use...

    Code:
    onload = functionName;

  8. #8
    Join Date
    Oct 2004
    Posts
    66
    That doesn't seem to be working hence why I asked.

  9. #9
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Code:
    function myFunction(){
     alert("Hello, Monkey-loving World!");
    }
    
    onload = myFunction;

  10. #10
    Join Date
    Oct 2004
    Posts
    66
    lol, that worked don't know why my fucntion isn't working though.

  11. #11
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    What is your function? (Yes, I am well aware of the possibility that your next reply will have a good 150+ lines of code. I've been through it today, it's not like more will make a difference. )

  12. #12
    Join Date
    Oct 2004
    Posts
    66
    Ok found what I think is the problem.

    PHP Code:
    document.getElementById('updateVar').innerHTMLdisplay
    When I remove this from my function all seems to be running fine.

  13. #13
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Is that an unnecessary part of your script or do you need to figure out how to make that part of the script work?

  14. #14
    Join Date
    Oct 2004
    Posts
    66
    I need to figure out how to make this part work.

  15. #15
    Join Date
    Jan 2003
    Location
    Texas
    Posts
    10,413
    Are you sure there is an element on your page that has an id="updateVar"? Also, is the variable display defined? If the answer to both questions is "yes," you'll have to show me more code.

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