IE8 标准模式:div 上的 onclick 处理程序不会触发 [英] IE8 Standards mode: onclick handler on div does not fire

查看:21
本文介绍了IE8 标准模式:div 上的 onclick 处理程序不会触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一排按钮(用于 BBcode),包含在各个位置.每个按钮都是一个具有固定尺寸的空 div、一个背景图像和一个 onclick 处理程序.到目前为止,这在所有浏览器中都运行良好.

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.

现在我又添加了这一行的一个实例,但这次它位于一个绝对定位的弹出 div 中.(至少这是我能想到的一个显着差异,因为否则它是完全相同的代码.)这也适用于除 IE8 之外的所有浏览器,在这些浏览器中单击按钮不会执行任何操作.除非我打开兼容模式,否则它工作得很好.

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.

难道没有其他方法可以让 Internet Explorer 表现得像它应该的那样吗?

Isn't there any other way to make Internet Explorer behave like it should?

推荐答案

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

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.

我在 CSS 中的解决方案:

My solution in CSS:

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

...其中 pixel.gif 是 1x1 透明图像.

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

这篇关于IE8 标准模式:div 上的 onclick 处理程序不会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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