Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#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:
Blocked by: Blocking:

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 (2)

comment:1 Changed 7 years ago by Rick Waldron

Resolution: invalid
Status: newclosed

inline event handlers are treated as properties, not attributes.

comment:2 Changed 7 years 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

Note: See TracTickets for help on using tickets.