Skip to main content

Bug Tracker

Side navigation

#4125 closed bug (wontfix)

Opened February 11, 2009 04:33PM UTC

Closed March 18, 2009 01:05AM UTC

href changing in IE

Reported by: john Owned by:
Priority: minor Milestone: 1.3.2
Component: core Version: 1.3.1
Keywords: Cc:
Blocked by: Blocking:
Description

When you attempt to change the href of an anchor in IE (of which the text value is identical to the href) the text value will be changed, as well. Some workaround should be provided for this.

Attachments (0)
Change History (4)

Changed February 12, 2009 04:03PM UTC by shadedecho comment:1

Just as an fyi, it seems it's IE actually comparing the underlying html inside the <a> tag to see if that identically matches the href url. Even if the rendered text is the same, but the html is different (for instance the / character replaced with an html entity, or some part of the link text is wrapped in a <span> or <b>, etc), IE will not mess with things. So the proper check to see if IE needs to be quirk-fixed is something like: $(this).html()===$(this).attr("href")

Two thoughts on a workaround:

1. Prevent IE from doing its dirty work by first breaking the exactness between the two properties. You could insert/append some invisible html entity (like <wbr> for instance?) to the html of the link first, then change the href, then remove the shim. That should fix the quirk, but also prevent any layout re-rendering "flashes" or other ugliness to users, giving a better user experience it would seem.

2. Or, you could let IE do its work and then clean it up. Thankfully IE lets you change the html right back after it messes with things. So, you can first capture/save the innerHTML of the link, then change its href, then change it's html right back. For good measure, you also temporarily set visibility:hidden on it while the flip occurs, to cut down on layout re-rendering "flashes". Maybe display:none is better, but then it moves surrounding content temporarily in to the real-estate taken up by the original link, causing the undesired layout-rerendering.

Changed February 12, 2009 04:14PM UTC by shadedecho comment:2

Follow up: I tried method #1 on my site and it works just great. Here's the code I used:

$(alink).html($(alink).html()+"<wbr>");
$(alink).attr({href:val});
$(alink).html($(alink).html().replace(/<wbr>$/i,""));

Changed March 17, 2009 10:42PM UTC by brandon comment:3

need: ReviewTest Case

Changed March 18, 2009 01:05AM UTC by brandon comment:4

resolution: → wontfix
status: newclosed

Should the core really try to fix this? Seems like such an edge case with a very simple workaround. Not even sure how this would fit into $.support.

I think this is better just documented.