Bug Tracker

Ticket #2558 (closed bug: fixed)

Opened 9 months ago

Last modified 7 months ago

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

Reported by: oridan Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.2.4 Component: core
Version: 1.2.3 Keywords:
Cc: Needs: Review

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.

Attachments

Change History

Changed 9 months ago by oridan

possibly related to #2511

Changed 8 months 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;

}

});

Changed 8 months ago by MelTraX

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

Changed 7 months ago by flesler

  • status changed from new to closed
  • resolution set to fixed

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.