Skip to main content

Bug Tracker

Side navigation

#2558 closed bug (fixed)

Opened March 19, 2008 03:28PM UTC

Closed May 13, 2008 12:30AM UTC

$(...).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.

Attachments (0)
Change History (4)

Changed March 19, 2008 03:29PM UTC by oridan comment:1

possibly related to #2511

Changed April 08, 2008 02:00PM UTC by MelTraX comment:2

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 April 08, 2008 02:02PM UTC by MelTraX comment:3

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

Changed May 13, 2008 12:30AM UTC by flesler comment:4

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');