Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    onLoad in <body>, is it necessary?

    in my body <>'s, do i have to include the onload part? i have it on all my webpages, but i'm not sure what it does.
    <body onLoad="window.onresize=new Function('if (navigator.appVersion==\'Netscape\') history.go(0);');">

    i do know this, every time i open one of my html docs from my harddrive, the yellow Internet Explorer Information bar pops up, and i have to click it and select 'allow blocked content'. i figured out that the error bar doesn't appear when i remove the onload stuff. as far as i know, it only happens when opening from the hd.

    thanks and peace

  • #2
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts
    The onLoad() function is a javascript function that can be used to do dynamic functions when the page loads into the browser. It is not needed if you do not want to do anything apart from load your page.

    I tend not to use this unless there is a necessity to do so - i.e. if I need to build a dynamic drop down menu or I have stored a cookie and want to display the contents of this cookie.

    Hope this makes sense.

    D.
    Daemonkin.
    If this was helpful, please add to my reputation
    Thousand Sons - Freelance Web Developer - ninetyonedegrees.com

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    The body tag should always be written <body>

    If you need to use a JavaScript onload call then place window.onload = in the JavaScript instead of polluting your HTML.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks folks, sounds like i can remove em, but i do have a few pages w/ some simple java stuff like script:window.external.AddFavorite and a statcounter, so i'll leave em on those pages.
    cheers


  •  

    Posting Permissions

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