By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,453 Members | 1,078 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,453 IT Pros & Developers. It's quick & easy.

How to get an object handle by Id properly in Javascript

P: n/a
<script type="text/javascript">
<!--
var Login1_UserNameRequired = document.all ?
document.all["Login1_UserNameRequired"] :
document.getElementById("Login1_UserNameRequired") ;

if (Login1_UserNameRequired)
{
// etc etc
}

-->
</script>

Sep 29 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

an******@hotmail.com wrote:
<script type="text/javascript">
<!--
Using <!-- ... --to "hide" code from browsers is prehistorical. You
should remove this.
var Login1_UserNameRequired = document.all ?
document.all["Login1_UserNameRequired"] :
document.getElementById("Login1_UserNameRequired") ;
This doesn't handle browser with neither document.all nor
document.getElementById (Netscape 4 comes to mind). Granted, Netscape 4
is obsolete, but so is document.all...
if (Login1_UserNameRequired)
{
Good practice. But what do you do it it's not defined? A good error
handling is the difference between a professional looking product and an
amateurish website.
// etc etc
}

-->
</script>
Greetings,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 29 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.