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

查看:259
本文介绍了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中的透明区域无法点击。一个简单的解决方案是将背景图像设置为透明 .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天全站免登陆