Re: Cross Browser Question : OnLoad
Quote:
Originally Posted by Frostie
Just wondered if anyone could shed any light in regards to the onload fucntion? I know it works fine in IE but wondered if anyone had any experience of onload causing any problem across any other browsers when its placed in the BODY tag?
If so, what alternatives are available that will work with the majority, if not all, browsers?
|
onload will work with all browsers - although obviously the script you're looking to run onload may have browser issues. As an alternative you can also do
Code:
<script type="text/javascript">
window.onload=function(){alert('test');};
</script>
which would do the same as
Code:
<body onload="alert('test');">
The first way might be easier as you can quickly add it to multiple pages without having to edit the body tag - also purists tend to prefer the fist. Both will work fine in all browsers.
Cheers,
Jon
|