5

Ok, this is going to be an interesting one...

Pretty much I seem to have run into an interesting IE bug (feature) involving when a span is inside an anchor eg.

<a href='#'>
    <span style="float:left;">Super cool link</span>
    <span style="float:right;">10</span>
</a>

In IE, you seem to be able to left click through but you cannot right click on the item and get the link menu, this problem seems to be persistent across Google's services too, eg.

IE Bug Example

I'm wondering if anyone could shed some light on

  1. The cause of why this is happening
  2. A solution to this or a workaround

So far I have tried adding a &nbsp; in the anchor and fiddled with z-indexes to no avail.

The only solution / workaround I can find is if you remove the Doctype the issue seems to go away. (not going to happen)

Ninja edit - You can't seem to CTRL + Click either

Ok another edit:

Looks like display: block; on the span kills it - http://jsfiddle.net/vdfhz/4/

csilk
  • 2,732
  • 3
  • 23
  • 40
  • are you trying to change IE right click context menu? – Ibu Nov 29 '12 at 03:43
  • that's an interesting one. I found the reason: it's because the span is floated. if you remove the float, it will work. I still haven't found a solution for if you want it to be floated however – kennypu Nov 29 '12 at 03:50
  • @Lbu no, just getting the IE right click context menu to show – csilk Nov 29 '12 at 03:54
  • @kennypu - check out Gmail, the spans inside the anchors (header) don't seem to be floated, still won't work – csilk Nov 29 '12 at 03:55
  • @Cub3: a fantastic find! it's a pet peeve of mine when expected behaviour is interfered with (commonly with `preventDefault` etc.) on js-level, but *ignoring user-initiated contextual menu when triggered from a block-level descendant of an anchor* is truly frustrating. Also: I never realised [how bad Microsoft's bug submission is](http://connect.microsoft.com/directory/internet/) (unless I'm looking in the wrong place) – Oleg Nov 29 '12 at 08:10
  • 1
    You are looking in the right place for submitting IE bugs to Microsoft. However, I couldn't reproduce this issue on IE10 for Windows 7 nor Windows 8 so it's unlikely that you'll get help there. – Don Cruickshank Jan 02 '13 at 22:59

5 Answers5

1

Ok, answering my own question, should have just spend more time on it.

Looks like if you have anything other than display: inline; on the span it won't work.

http://jsfiddle.net/vdfhz/9/

Thanks for giving it a go everyone, hope this will help someone in the future

csilk
  • 2,732
  • 3
  • 23
  • 40
  • 1
    no such thing as `display:relative`, IE simply ignores and the element's default `display:inline` persists – Oleg Nov 29 '12 at 04:17
  • 1
    Sorry, brain fart, has been a long day, display: inline; is what I meant. – csilk Nov 29 '12 at 04:43
1

Your anchor element's hasLayout (IE property) is false.

This issue arises when you have only elements that hasLayout=true within an anchor that hasLayout=false.

a *{float:left;}

Demo (run in IE): http://jsfiddle.net/52A6L/ (notice the border around the link, that's your clickable area)

About hasLayout: http://msdn.microsoft.com/en-us/library/ie/ms530764(v=vs.85).aspx

You can fix this situation by having layout for the anchor OR not having layout for the spans. Not having layout for the span: http://jsfiddle.net/52A6L/1/ Having layout for the anchor: http://jsfiddle.net/52A6L/2/

The examples are simply examples. Please refer to the documentation on MSDN and pick the approach that causes least headaches for the rest of the layout.

Jani Hyytiäinen
  • 5,293
  • 36
  • 45
0

Not sure why it behaves off, but how about using a paragraph tag instead?

daniel
  • 1,435
  • 9
  • 16
  • Really? I get 2 different context menus in IE9 - http://jsfiddle.net/vdfhz/5/ - wasn't that the issue? – daniel Nov 29 '12 at 04:02
  • You get the link context menu on the not on the

    Yes that is the issue, just updated the question above, looks like if you have a display: block; on the span it won't work - http://jsfiddle.net/vdfhz/4/

    – csilk Nov 29 '12 at 04:04
0

you could always use display:inline-block; just to be on the safe side.

Also if you have floated elements inside a wrapper element (like an a tag) it needs to be cleared out.

So a quick and dirty way to do it would be:

<a href='#'>
    <span style="float:left;">Super cool link</span>
    <span style="float:right;">10</span>
    <div style="clear:both;"></div>
</a>

Hopefully that helps.

Eddie
  • 146
  • 2
  • 7
0

First i need to say that i can't test if the following informations will help you because i don't have IE here right now.

But many bugs in IE can be solved if you add zoom : 1 to the element that does behave the wrong way.

Another thing that can sometimes be responsible for incorrect behavior in IE is, when an element is rendered as block element inside of an inline element. So if <a> is still inline and <span> is rendered as block element, this could be the reason for your problem.

t.niese
  • 39,256
  • 9
  • 74
  • 101