【问题标题】:Exception thrown with adsense on Internet Explorer在 Internet Explorer 上使用 adsense 引发的异常
【发布时间】:2017-07-13 21:16:29
【问题描述】:

我已将 Google 分发的 adsense javascript 代码复制并粘贴到我的 HTML 标记中 -

        <ins class="adsbygoogle"
             style="display:inline-block;width:234px;height:60px"
             data-ad-test="on"
             data-ad-client="XXXXX"                  
             data-ad-slot="XXXXX"></ins>
        <script>
            (adsbygoogle = window.adsbygoogle || []).push({});
        </script>

[在此处粘贴代码时,我将实际的 data-ad-client 和 data-ad-slot 值替换为 XXX]

它在 Chrome、Firefox、Edge 上运行良好,但在 Internet Explorer 上我遇到了异常。它说“Javascript 运行时错误:无法在 r.crypto.getRandomValues(d) 上获取属性 'getRandomValues'of undefined or null reference';adsense 脚本中的函数调用。

不知道发生了什么。任何帮助表示赞赏。

【问题讨论】:

    标签: javascript internet-explorer adsense


    【解决方案1】:

    您的代码正在模拟旧版本的 IE。

    您可以使用此脚本测试最新的加密货币:

    <!DOCTYPE html>
    
    <html>
    <head>
      <meta charset="utf-8" />
      <title>Web Cryptography API</title>
    </head>
    
    <body>
      <script>
    
        var crypto = window.crypto || window.msCrypto;
    
        if (crypto) {
          console.log(crypto);
          
        } else {
          console.log("Unable to create window.crypto object");
        } 
      </script>
    </body>
    </html>

    您可以在开发者工具中查看您正在运行的模式:

    【讨论】:

    • 在我的机器上运行良好。没有问题。不确定问题是加密 API 还是其他触发它的东西。
    【解决方案2】:

    没有设法完全解决它,但我将 Visual Studio 设置为不理会该异常,并且一切正常。最终切换到 DFP,所以如果有人仍然关心,这不再是问题。

    【讨论】:

      猜你喜欢
      • 2016-01-28
      • 2012-01-25
      • 1970-01-01
      • 1970-01-01
      • 2018-07-25
      • 1970-01-01
      • 1970-01-01
      • 2014-10-29
      • 2019-08-30
      相关资源
      最近更新 更多