2017-07-17 67 views
1

我剛剛在magento 2.x中實施了trustpilot carousel集成。爲此,我創建了一個簡單的插件,將所需的數據插入文檔的頭部和主體(使用laoyout文件和.phtml)。下面是代碼:Trustpilot cross-oirigin error with carousel integration

XML:

<?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:

<!-- 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集成工具生成該代碼。它工作得很好,但是當我加載頁面我得到這個例外在檢查控制檯:

未捕獲拋出:DOMException:無法讀取「HTMLIFrameElement」的「contentDocument」屬性:訪問一個封閉的起源「一幀」跨域框架

使用chrome進行調試後,我發現這發生在Trustpilot將一些iframe加載到我的網頁中時發生。任何想法如何發生這種情況,或者我可以如何防止它?

+0

看起來像您網站上的某些內容正嘗試讀取Trustpilot域中投放的注入iframe上的'contentDocument'屬性。我會建議掃描你的腳本'contentDocument'。 –

+0

謝謝,但這不會發生在我們的其他網站上。目前正與Trustpilot支持聯繫。解決後會報告回來。 –

回答