不同域的iframe中无法使用“pseudoclass:active”。
创始人
2025-01-09 23:00:51
0

此问题的解决方法是在子域中添加一段 JavaScript 代码来处理此问题。假设您的 iframe 具有 ID“my-iframe”,以下是解决方法的代码示例:

var myIframe = document.getElementById('my-iframe');
if (myIframe) {
  // Add event listener for when the iframe is loaded
  myIframe.addEventListener('load', function() {
    // Get the iFrame's document object
    var iFrameDoc = myIframe.contentDocument;
    if (iFrameDoc) {
      // Add event listener for when the iframe's document is clicked
      iFrameDoc.addEventListener('click', function() {
        // Set the active state on the parent window
        document.body.classList.add('active');
        // Remove the active state after a short delay (to allow the user to see the active state)
        setTimeout(function() {
          document.body.classList.remove('active');
        }, 200);
      });
    }
  });
}

此代码添加了一个事件监听器,当 iframe 加载时启动。通过监听 click 事件,它将在主窗口中添加一个名为“active”的类来模拟 :active 伪类的行为。这使您可以使用 CSS 来更改子域中 iframe 的样式,就像在同一域中一样。

相关内容

热门资讯

黑科技辅助挂!(德州aapok... 黑科技辅助挂!(德州aapoker)透明挂辅助挂,(AAPOker)从来存在有挂,系统教程(有挂神器...
德州之星辅助器怎么用!wpk机... 1、德州之星辅助器怎么用!wpk机制,德州之星辅助,新版2025教程(最初真的是有挂);详细教程。2...
黑科技了解!(pokermas... 黑科技了解!(pokermaster)外挂辅助机制,(聚星扑克德州)切实是有挂,揭秘教程(有挂技巧)...
aapoker发牌机制!aap... 1、aapoker发牌机制!aapoker安卓怎么下载,wpk微扑克有辅助吗,规律教程(一向是有挂)...
黑科技计算!(德扑ai)外挂辅... 黑科技计算!(德扑ai)外挂辅助神器,(德扑ai)从来存在有挂,规律教程(有挂辅助),支持语音通讯、...
wepoke黑科技!wpk使用... 这是一款非常优秀的wpk使用ai辅助会封号吗 ia辅助检测软件,能够让你了解到wpk使用ai辅助会封...
aapoker发牌机制!微扑克... aapoker发牌机制!微扑克系统的发牌速度有多快,众合推扑克有没有辅助,新版2025教程(固有真的...
黑科技辅助!(WpK)透视辅助... 此外,数据分析德州(wpK)辅助神器app还具备辅助透视行为开挂功能,通过对客户wpK透明挂的深入研...
wepoker有外挂吗!wop... 此外,数据分析德州(aapoker有伙牌吗)辅助神器app还具备辅助透视行为开挂功能,通过对客户aa...
黑科技好友!(wePOke)软... 黑科技好友!(wePOke)软件透明挂,(wEpOke)固有是真的有挂,2025新版技巧(有挂神器)...