首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带旋转木马集成的Trustpilot交叉-oirigin误差

带旋转木马集成的Trustpilot交叉-oirigin误差
EN

Stack Overflow用户
提问于 2017-07-17 13:23:15
回答 1查看 760关注 0票数 1

我刚刚在Magento2.x中实现了trustpilot旋转木马集成。为此,我创建了一个简单的插件,它将所需的数据插入文档的头部和正文(使用laoyout文件和.phtml)。以下是代码:

xml:

代码语言:javascript
复制
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <script src="https://widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js" src_type="url" />
    </head>
    <body>
        <referenceContainer name="content">
            <block class="\Magento\Framework\View\Element\Template" name="<vendor>.trustpilot"
                   template="<vendor>_Trustpilot::trustpilot.phtml"/>
        </referenceContainer>
    </body>
</page>

phtml:

代码语言:javascript
复制
<!-- TrustBox widget - Carousel -->
<div class="trustpilot-widget" data-locale="en-US" data-template-id="<template-id>" data-businessunit-id="<businessunit-id>" data-style-height="130px" data-style-width="100%" data-theme="light" data-stars="4,5" data-schema-type="Organization">
    <a href="<correct-url>" target="_blank">Trustpilot</a>
</div>
<!-- End TrustBox widget -->

此代码是使用trustpilot集成工具生成的。它工作得很好,但是当我加载页面时,我在检查器控制台中得到了这个异常:

Uncaught :未能从‘HTMLIFrameElement’中读取“contentDocument”属性:阻止具有原点的帧“访问跨原点帧”。

在使用chrome进行调试之后,我发现当trustpilot将一些iframe加载到我的网页上时,就会发生这种情况。你知道这是怎么发生的或者我怎么能阻止它吗?

EN

回答 1

Stack Overflow用户

发布于 2017-07-20 15:47:33

这是magento的问题。较小的2.2版将不包含修补程序(尚未发布)。当插入元素时,magento总是尝试通过contentDocument访问iframes。在此提交中找到了对此的官方修复:

https://github.com/magento/magento2/commit/3026e814e236d28d54b5fdb57c7da163ed4c7be4

应用后,错误消失了。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45145485

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档