View Full Version : onLoad in <body>, is it necessary?

07-10-2007, 09:51 AM
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

07-10-2007, 10:02 AM
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.


07-10-2007, 10:36 AM
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.

07-10-2007, 12:38 PM
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.