【问题标题】:Ignore pointer-events inside iframe忽略 iframe 中的指针事件
【发布时间】:2018-10-27 16:32:52
【问题描述】:

我希望有可能点击 iframe 内的链接,并能够在按钮附近但仍在 iframe 内执行任何鼠标操作。

当我将 pointer-events: none; 添加到整个 iframe 并尝试通过将 pointer-events: all; 设置为按钮(我可以编辑 iframe 源)来忽略它时,看起来仍然不接受此规则。

有谁知道这是否可能? iframe 的大小必须更大,因为在单击按钮后内容会发生变化,并且会出现按钮上方的元素。

这里是链接:https://jsfiddle.net/fnv4vct6/2/

【问题讨论】:

    标签: html css iframe


    【解决方案1】:

    试试这个:

    iframe {
      position: fixed;
      bottom: 0;
      right: 0;
      border: 1px solid #000;
      pointer-events: all;
      height: 400px;
    }
    
    iframe > * {
      pointer-events: none;
    }
    

    How can you make an iframe have pointer-events: none; but not on a div inside that?

    【讨论】:

    • 之后我可以点击按钮,但不能在 iframe 后面标记文本。
    • 那么你希望能够通过iframe点击,还可以点击按钮?我相当确定这是不可能的,因为如果您让 iframe 获取指针事件(您必须能够单击按钮),那么您将无法在它后面单击。也许其他人知道怎么做。
    猜你喜欢
    • 2014-04-29
    • 2014-06-23
    • 1970-01-01
    • 1970-01-01
    • 2015-12-27
    • 1970-01-01
    • 1970-01-01
    • 2011-11-02
    • 1970-01-01
    相关资源
    最近更新 更多