SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: onload

  1. #1
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Earth
    Posts
    724
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onload

    Hey,

    I thought this to be the correct way to use onload inside javascript tags aposed to witihn the body tag..

    <script type="text/javascript">
    <!--
    onLoad=AjaxRequest('main','./includes/display.php?id=0')
    // -->
    </script>

    Doesnt appear to work.. Is it incorrect?

    Thanks

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by _matrix_ View Post
    Doesnt appear to work.. Is it incorrect?
    Your code seems to reply on other things are aren't present in you example, so a link to your page that demonstrates the problem would be most helpful.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Earth
    Posts
    724
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    onLoad=AjaxRequest('main','./includes/display.php?id=0') works fine within the body tag.. But I want to place it in the head tag within javascript tags instead..

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by _matrix_ View Post
    onLoad=AjaxRequest('main','./includes/display.php?id=0') works fine within the body tag.. But I want to place it in the head tag within javascript tags instead..
    Something else on your page might be replacing that onload event, or it cold be something else, which is why we need to see the problem as you experience it on your own test page.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Earth
    Posts
    724
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its sorted.. had to place the code nearer to the bottom of the page apossed to in the head tags..

    Thanks

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,603
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    There's no such action as onLoad as JavaScript is case sensitive and requires event handlers names to be all lowercase.

    Also onload effectively became obsolete when people started using the best practice of placing their scripts at the very bottom of the page where they don't slow the loading of the page and where everything they need to reference will have already loaded.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  7. #7
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Earth
    Posts
    724
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sweet.. thanks for the info..


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
  •