可点击标签在IE 8中不起作用 [英] Clickable label not working in IE 8

查看:131
本文介绍了可点击标签在IE 8中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下列表项目:

 < li> 
< input value =someRadioButtonname =ctl00 $ mainContent $ grouptype =radio
id =ctl00_mainContent_somelRadioButtononclick =showSomeInfo()/>
< label for =ctl00_mainContent_someRadioButton>
< img class =extraPadding-Right-10src =https://xxy.com/some_mark_37x23.gif/>
< / label>
< / li>

所以显示的是单选按钮和旁边的图片。当我在FireFox中时,Chrome和Safari单击该图像会触发收音机onclick中指定的showSomeInfo()。我不知道为什么我猜,因为它被包裹在一个标签中,并且该标签与该单选按钮有关。......

但无论如何这不是我的问题。当你点击图片时,我喜欢那个javascript方法showSomeInfo()被调用。但问题是,它可以在除IE 8以外的所有浏览器中运行。如果我在IE 8中打开此页面,单击该图像将不会执行任何操作,我不知道为什么。我对此感到莫名其妙。

解决方案

它在Firefox和Firefox中的工作方式的原因在于, code>< label> 当它有一个指向输入字段的for属性(通过id值)时应该这样做。如果它在IE中不能以这种方式工作,那是因为微软要么以不同的方式来解释标准,要么就是没有正确实现标准。 (我在w3c参考文献中没有看到任何明确的语言,我发现它规定了标签的文本内容是否应该关注并转移它。)


I've got the following list item:

<li>
    <input value="someRadioButton" name="ctl00$mainContent$group" type="radio"
        id="ctl00_mainContent_somelRadioButton" onclick="showSomeInfo()" />
    <label for="ctl00_mainContent_someRadioButton">
        <img class="extraPadding-Right-10" src="https://xxy.com/some_mark_37x23.gif" />
    </label>
</li>

So what shows up is a radio button and an image next to it. When I am in FireFox, Chrome, and Safari clicking on that image fires the showSomeInfo() that's specified in the radio's onclick. I'm not sure why I guess because it's wrapped in a label and that label is relating to that radio button....

But anyway that's not my problem. I like that when you click the image, that javascript method showSomeInfo() is called. But the problem is that it works in all browsers except IE 8. If I open this page in IE 8, clicking on the image does nothing and I'm not sure why. I'm baffled at this one.

解决方案

The reason it works the way it does in Firefox et al is that that's what <label> is supposed to do when it's got a "for" attribute that points to an input field (by "id" value). If it doesn't work that way in IE, it's because Microsoft either interpreted the standard differently or simply failed to implement it correctly. (I don't see any clear language in the w3c reference I found to stipulate whether anything but text content of a label should get focus and transfer it.)

这篇关于可点击标签在IE 8中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆