IE8 标准模式:div 上的 onclick 处理程序不会触发
在我的应用程序中,我有一行按钮(用于 BBcode),包含在各个位置。每个按钮都是一个具有固定尺寸的空 div、一个背景图像和一个 onclick 处理程序。到目前为止,这在所有浏览器中都运行良好。
现在我又添加了这一行的一个实例,但这一次它位于绝对定位的弹出 div 内。 (至少这是我能想到的一个显着差异,因为否则它是完全相同的代码。)这也适用于除 IE8 之外的所有浏览器,在 IE8 中单击按钮不会执行任何操作。除非我打开兼容模式,在这种情况下它工作得很好。
难道没有其他方法可以让 Internet Explorer 表现得像它应该的那样吗?
In my application I have a row of buttons (for BBcode) that is included in various places. Each button is an empty div with fixed dimensions, a background image and an onclick handler. This has worked very well in all browsers - so far.
Now I have added one more instance of this row, but this time it is inside an absolutely positioned pop-up div. (At least that's the one notable difference that I can think of, because otherwise it's the exact same code.) This also works in all browsers except for IE8, where clicking the buttons does not do anything. Unless I switch on compatibility mode, in which case it works pretty much fine.
Isn't there any other way to make Internet Explorer behave like it should?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在 IE8 中也遇到了同样的问题。 DIV 中的透明区域不可单击。一个简单的解决方案是将
background-image
设置为透明的.gif
。我的 CSS 解决方案:
...其中
pixel.gif
是 1x1 透明图像。I had the same problem in IE8. The transparent areas in the DIVs were not clickable. An easy solution is to set the
background-image
to a transparent.gif
.My solution in CSS:
...where
pixel.gif
is a 1x1 transparent image.我找到了解决方案。正是按钮上的“float:left”属性导致了它失败。
这很奇怪,因为在包含此代码的所有其他地方,它也有浮动 - 并且它有效。即使在 IE8 中也是如此。
不管怎样,删除它并使用“display:inline-block”来放置就可以了。
I've found the solution. It was the "float:left" attribute on the buttons that made it fail.
Which is rather strange because in all the other places where this code was included, it also had the float - and it worked. Even in IE8.
Anyway, removing it and using "display:inline-block" for the placement did the trick.