开发者

Anchor tag with image links to image instead of href in Internet Explorer 9 Standards mode

In my site layout, we have the standard company logo image in the upper left hand corner that links back to the home page. The html is simple -

<a href="/">
  <img src="/Images/imageName.png" alt="Company Home" height="" width="" />
</a>

Hovering over the image shows the URL, and it works as expected in all browsers except IE 9. When clicking the image in IE 9, instead of linking to the home page it links to the image itself.

The developer tools say Browser Mode: IE 9,开发者_开发百科 Document Mode: IE9 standards. The doctype being used is XHTML transitional (I'm not going to be able to switch the doctype). Switching the Document Mode in the dev tools to IE8 Standards fixes the issue. This appears to only affect IE 9.

Has anyone run into this before? I've tried hard coding a fully qualified or different url (http://www.google.com) and still get the image on click.


After some additional digging, it turns out that the issue was actually buried in some javascript from one of our analytics vendors.

A combination of IE 9 making addEventListener() available and an anchor tag's pathname property returning "" in IE and "/" in other browsers caused some logic to fail in IE 9 that was skipped over in other versions.

Eric Lawrence has a blog post about the pathname issue -

http://blogs.msdn.com/b/ieinternals/archive/2011/02/28/internet-explorer-window-location-pathname-missing-slash-and-host-has-port.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜