iframe with pointer-events:none;但是里面有一个div,它有指针事件:auto; [英] iframe with pointer-events: none; but with a div inside it that has pointer-events: auto;

查看:1008
本文介绍了iframe with pointer-events:none;但是里面有一个div,它有指针事件:auto;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能有一个带指针事件的外部div:none;和另外一个div里面的指针事件:auto;外部div对于点击事件将是透明的(即它不会对点击事件做出反应,但底层的html控件将不会),内部的将会。

It is possible to have an outer div with pointer-events: none; and another div inside it with pointer-events: auto;. The outer div will be transparent to click events (ie it won't react to click events but underlying html controls will) and the inner one will.

然而,我现在有一个场景,我需要与iframe做同样的事情,但它不工作。我设置指针事件:none;在iframe上,但是那些应该是可点击的内部div不是即使它们有指针事件:auto;设置。

However, I now have a scenario where I need to do the same thing with an iframe, but it is not working. I set pointer-events: none; on the iframe, but then the inner divs that should be clickable are not even if they have pointer-events: auto; set.

这里还有另一个类似的问题,但是已经被关闭为脱离主题。我不明白为什么这是一个非常有效的html / css问题。

There is another similar question here, but is has been closed for being off-topic. I don't understand why. It is a very valid html/css question.

推荐答案

iFrames被视为单个内容而不是页面的一部分iFrame所在的地方,所以不,不可能。

iFrames are treated as a single piece of content and not part of the page in which the iFrame resides, so, no, it is not possible.

渲染器和DOM将iFrame视为黑盒子。这就是为什么你不能像例如 iFrameElement.childNodes [0] 和类似的(并获得< html> / code> iFrame)。你必须运行 iFrameElement.contentWindow.document.documentElement 或类似的东西。这是一个完全独立的浏览环境。

The renderer and DOM are treating the iFrame as a black box. This is exactly why you cannot, for example, run regular methods like iFrameElement.childNodes[0] and similar (and get the <html> of the iFrame). You have to run iFrameElement.contentWindow.document.documentElement or something like that. It is a completely separate browsing context.

这篇关于iframe with pointer-events:none;但是里面有一个div,它有指针事件:auto;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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