Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: JavaScript
Expertise: Intermediate
Mar 5, 2007

Javascript Errors in Firefox

Because browsers other than IE don't create global variables for every part of the page/DOM, you need to qualify references to the form and its elements in non-IE browsers. You can do this either by creating a form reference and passing that to methods, or by using an absolute reference to the document.forms collection in your code. For example:

// the code below works fine in IE.
<HTML>
<SCRIPT language="javascript">
function OnLoad()
{
//Works fine in IE and not in Firefox
frmName.SearchButton.disabled = true

//Replace the above line with the below one

//Works fine in both IE and Firefox
document.frmName.SearchButton.disabled = true 
} 
</SCRIPT>
<BODY onLoad = "onLoad()">
<form name="frmName">
<input id="SearchButton" name="SearchButton" type="button">
</BODY>
</HTML>
Balasubramanian Krishnaswamy
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap