Bug Tracker

Modify

Ticket #11739 (closed bug: invalid)

Opened 13 months ago

Last modified 13 months ago

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

inline event handlers are treated as properties, not attributes.

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.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.