Ticket #11739 (closed bug: invalid)
Attr on a "javascript:" will return a function in IE 7
| Reported by: | Kumu | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | 1.7.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Came across issue when trying to calling: $("#dropdownid").attr("onchange") in IE7
$("#dropdownid").attr("onchange") value is "javascript:dosomething()"
on other browsers it returns a string of "javascript:dosomething()" which is the correct behavior defined in the documents, but when running this function in IE7 it returns a function:
function onchange(){
dosomething();
}
Suggestion:
ret = elem.getAttribute( name );
if(typeof ret === "function"){
//use getAttributeNode only if needed due to efficiency
ret = elem.getAttributeNode(name);
}
Change History
comment:1 Changed 13 months ago by rwaldron
- Status changed from new to closed
- Resolution set to invalid
comment:2 Changed 13 months ago by dmethvin
The specific issue here is that IE7 treats attributes and properties the same, kind of like jQuery itself did before 1.6.
I don't understand what kind of code is looking at the onchange attribute string and trying to do something with it. If you just need to know if one is present, that is still possible given what is currently returned. Otherwise, this probably applies: http://docs.jquery.com/Won't_Fix#Inline_Event_Handlers
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

inline event handlers are treated as properties, not attributes.