View Full Version : meaning of var, IE
11-17-2010, 12:04 AM
This prbl. appears only in IE:
l2 = obj.parentNode.getElementsByTagName("select").value;
--> object does not support this property or method
var l2 = obj.parentNode.getElementsByTagName("select").value;
11-17-2010, 12:13 AM
You probably have some tag on your page with that name or id.
That is, maybe <input name="l2"> or <td id="l2">.
IE *automatically* exposes such names and id's as global (page scope) variables.
By prefixing your name with var, you are forcing IE to *not* use the default name/id mapping.
Simple as that. Been discussed here many times, mostly by Philip.
11-17-2010, 12:25 AM
jp, that is it, thanks.
11-17-2010, 09:11 AM
As an aside, I would always avoid variable names such as l2 as it is too easily confused with number 12.
11-17-2010, 10:32 PM
Yeah, I try to avoid variable names that start with lower case L and upper case i and o just for that reason. Even in my Java and C++ code. Willing to live with lower case L internally in variable names, esp. if the name is meaningful and the letter's use is obvious.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.