[jQuery] jQuery - attr method - Error Object required - Only in IE8
hi,
hi,
Could any one help me with this,
i am using jquery version - jQuery 1.1.3.1, there is a module to set
some values
so when i click on the submit button i get the following error (only
in ie8)
[[Webpage error details]]
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/
4.0; GTB6; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
Timestamp: Fri, 26 Jun 2009 13:45:29 UTC
Message: Object required
Line: 455
Char: 1
Code: 0
URI: http://domain.com/html/js/jquery/jquery.js
Code :
attr: function(elem, name, value){
var fix = jQuery.isXMLDoc(elem) ? {} : jQuery.props;
// Certain attributes only work when accessed via the old DOM 0 way
if ( fix[name] ) {
if ( value != undefined ) elem[fix[name]] = value;
return elem[fix[name]];
} else if ( value == undefined && jQuery.browser.msie &&
jQuery.nodeName(elem, "form") && (name == "action" || name ==
"method") )
{
return elem.getAttributeNode(name).nodeValue;
}
// IE elem.getAttribute passes even for style
else if ( elem.tagName ) {
if ( value != undefined ) elem.setAttribute( name, value );
if ( jQuery.browser.msie && /href|src/.test(name) && !
jQuery.isXMLDoc(elem) )
return elem.getAttribute( name, 2 );
return elem.getAttribute( name );
// elem is actually elem.style ... set the style
} else {
// IE actually uses filters for opacity
if ( name == "opacity" && jQuery.browser.msie ) {
if ( value != undefined ) {
// IE has trouble with opacity if it does not have layout
// Force it by setting the zoom level
elem.zoom = 1;
// Set the alpha filter to set the opacity
elem.filter = (elem.filter || "").replace(/alpha\([^)]*\)/,"") +
(parseFloat(value).toString() == "NaN" ? "" : "alpha(opacity=" +
value * 100 + ")");
}
return elem.filter ?
(parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) /
100).toString() : "";
}
name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase
();});
if ( value != undefined ) elem[name] = value;
return elem[name];
}
},
In case i comment the following line from the above code
[[
else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName
(elem, "form") && (name == "action" || name == "method") )
{
return elem.getAttributeNode(name).nodeValue;
}
]]
there is no error, but i am not sure whether commenting it wont effect
any other functionality which uses jquery...
and i am not able to track from which function this attr gets
called.....,
If you could actually explain me what does the above code do, than
also it may be helpfull...
Thanking you