Bug Tracker

Opened 12 years ago

Closed 12 years ago

#2558 closed bug (fixed)

$(...).attr returns different values in IE7 and Firefox

Reported by: oridan Owned by:
Priority: major Milestone: 1.2.4
Component: core Version: 1.2.3
Keywords: Cc:
Blocked by: Blocking:

Description

$(...).attr('onclick')

firefox:

returns the text contained within the onclick attribute.

IE7:

returns a reference to an anonymous function.

Expected:

return text contained within the attribute, as per firefox.

Change History (4)

comment:1 Changed 12 years ago by oridan

possibly related to #2511

comment:2 Changed 12 years ago by MelTraX

This 'error' also occurs for IE6.. I'm using a quick fix now which might help you to integrate a proper fix into jQuery:

$.fn.extend({

'onclickValue': function() {

var onclick = this.attr('onclick'); if($.isFunction(onclick))

return (onclick+).substr(23,(onclick+).length-25);

else

return onclick;

}

});

comment:3 Changed 12 years ago by MelTraX

Hmm.. The italic part should have two (onclick+{emptystring}) and a linebreak was lost but I guess you get the picture ;)

comment:4 Changed 12 years ago by flesler

Resolution: fixed
Status: newclosed

This could be patched on .attr(), but would change the behavior for anything else. To get the text on firefox, just use: this[0].getAttribute('onclick');

Note: See TracTickets for help on using tickets.