IE8 标准模式:div 上的 onclick 处理程序不会触发

发布于 2024-09-10 14:13:13 字数 299 浏览 2 评论 0原文

在我的应用程序中,我有一行按钮(用于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

过气美图社 2024-09-17 14:13:13

我在 IE8 中也遇到了同样的问题。 DIV 中的透明区域不可单击。一个简单的解决方案是将background-image 设置为透明的.gif

我的 CSS 解决方案:

background-image: url("images/pixel.gif"); 

...其中 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:

background-image: url("images/pixel.gif"); 

...where pixel.gif is a 1x1 transparent image.

我只土不豪 2024-09-17 14:13:13

我找到了解决方案。正是按钮上的“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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文