Thursday, April 5, 2007

Issues with window.onload()

Issues with window.onload()

This post is to show the variations you'll found when trying to make few controls invisible on the 'OnLoad' event of body.

If you write a script as below at the Bottom, this will produce error in IE, but not in Mozilla.
But if this same script is been written at the Top, then
his will produce error in IE & Mozilla both.

<script language="javascript">

Hence the solution is, write it using Inline Function as below, and place it either at top or bottom.

<script language="javascript">
window.onload=function() {HideMe();}

Below is the used HideMe() function.

function HideMe()
var lblLanguage=document.getElementById('labelLanguageError');'hidden';

Note: You can place the window.onload() = ......,, either at the top or bottom. It does not matter.
But better to place it at the bottom.

Hope it is clear now.


No comments:

Post a Comment