我正在开发一个项目,通过在图表上显示渐变 PNG 来增强高图表。我们使用 CSS pointer-events:none;
来允许用户与图表交互,尽管顶部有一个 div。 IE 无法识别pointer-events:none;
,因此 IE 上的用户要么无法增强图表设计,要么无法与图表交互。我正在寻找一种方法让 IE 允许鼠标事件(特别是悬停事件)通过 div 传递到其下面的元素。
您可以在此处查看我们正在使用的模型:http://jsfiddle.net/PFKEM/2/
有没有办法让 IE 执行类似 pointer events:none;
的操作,其中鼠标事件通过元素传递给元素来触发它们?
I'm working on a project where we are enhancing highcharts by displaying a gradient PNG over the charts. We are using CSS pointer-events:none;
to allow users to interact with the chart despite there being a div layered over the top. IE doesn't recognize pointer-events:none;
, so users on IE either can't have enhanced chart design, or can't interact with the charts. I'm looking for a way to get IE to allow mouse events (specificaly hover events), to pass through a div to the elements below it.
You can see a model of what we're working with here: http://jsfiddle.net/PFKEM/2/
Is there a way to get IE to do something like pointer events:none;
, where mouse events pass through an element to elements blow them?
发布评论
评论(6)
Internet Explorer 识别指针事件:无,但仅适用于 SVG 元素,因为指针事件仅在 W3C 规范中为 SVG 元素指定 (http://www.w3.org/TR/SVG/interact.html#PointerEventsProperty)。
你可以尝试这样的东西...
CSS:
HTML:
这适用于 IE9 和 IE10(我测试过)。如果您尚未使用 SVG 元素,则可以将现有元素包装在 SVG 中。 jQuery 库为此提供了一个包装方法 (http://api.jquery.com/wrap/ )。
有一篇非常好的德语文章详细分析了指针事件属性的特征:http://www.bennyn.de/programmierung/html/unterschiedliche-implementierungen-der-eigenschaft-pointer-events.html - 在那里你会找到(借助谷歌翻译)更多信息。
希望我能帮助
本
尼如果要访问上层和下层对象,则可以使用 IE 中的 document.msElementsFromPoint 方法 (http://msdn.microsoft.com/de-DE/library/windows/apps/hh465811.aspx)。它将为您提供数组中给定点上的所有图层。
The Internet Explorer recognizes pointer events: none, but only for SVG elements because pointer-events are only specified for SVG elements in the W3C specification (http://www.w3.org/TR/SVG/interact.html#PointerEventsProperty).
You can try it with something like this...
CSS:
HTML:
This works in IE9 and IE10 (I tested it). If you are not yet using SVG elements, then there is the posibility to wrap your existing elements in a SVG. The jQuery library provides a wrap method for that (http://api.jquery.com/wrap/).
There is a very good German article that has broken down the characteristics of the pointer events property: http://www.bennyn.de/programmierung/html/unterschiedliche-implementierungen-der-eigenschaft-pointer-events.html - There you will find (with the help of Google Translate) more information.
Hope I could help
Benny
P.S. If you want to access overlying and underlying objects, then you can use the document.msElementsFromPoint method in IE (http://msdn.microsoft.com/de-DE/library/windows/apps/hh465811.aspx). It will give you all layers on a given point in an array.
刚刚花了两天时间为 IE10 项目研究这个问题(IE10 不支持指针事件:无 CSS 属性,由于可能存在点击劫持问题,MS 投票支持撤销该规范)。
解决方法是使用 INLINED SVG 标签并在 SVG 中设置指针事件。
我一直尝试使用例如带有 SVG src 的 IMG 标签,或者将背景图像设置为 SVG 文件的 DIV(其中我使用pointer-events =“none”),甚至 SVG data-uris,但它没有我没想到将它放在一个单独的元素中恰恰需要未实现的pointer-events CSS 属性。
所以你需要一个像这样的简单的SVG:首先是一些CSS,例如:
然后是HTML:
参考:https://bug-45467-attachments.webkit.org/attachment.cgi?id=67050
Just spent two days researching this for an IE10 project (IE10 doesn't support the pointer-events: none CSS property, MS voted for withdrawal of the spec because of possible clickjacking issues).
Workaround is to have INLINED SVG tag and set pointer-events in SVG.
I kept trying to use e.g. an IMG tag with SVG src, or a DIV with background-image set to a SVG file (where I'd use pointer-events="none"), even SVG data-uris, but it didn't occur to me that having it in a separate element precisely required the unimplemented pointer-events CSS property.
So you need a bare-bones SVG like this: First some CSS e.g.:
And then in HTML:
Reference: https://bug-45467-attachments.webkit.org/attachment.cgi?id=67050
这是另一个非常容易用 5 行代码实现的解决方案:
例子:
Here is another solution that is very easy to implement with 5 lines of code:
Example:
http://jsfiddle.net/yckart/BQw4U/
http://jsfiddle.net/yckart/BQw4U/
CSS:
旧 HTML:
新 HTML:
CSS:
OLD HTML:
NEW HTML:
添加以下 CSS 将禁用 ms 指针。
Adding the following CSS will disable ms pointers.