![](/img/trans.png)
[英]The frame requesting access has a protocol of “https”, the frame being accessed has a protocol of “http”. Protocols must match
[英]The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "chrome-extension". Protocols must match
未捕獲的安全錯誤:阻止來源為“brickseek.com”的框架訪問來源為“chrome-extension://id”的框架。 請求訪問的框架協議為“https”,被訪問的框架協議為“chrome-extension”。 協議必須匹配。
我在嘗試替換 ap 標簽中的文本時遇到問題。 我已經嘗試了幾種方法來通過 id 獲取元素並替換文本但沒有運氣。 我不明白這個安全錯誤告訴我什么,因為我已經將 iframe 注入到網站中,但在嘗試操作它時,程序認為它屬於該網站。 我真的需要幫助為學校解決這個問題。
Content.js 我創建的地方 iframe
var iframe = document.createElement ('iframe');
iframe.src = chrome.extension.getURL ('iframe.html');
var topview = document.getElementById('sidebar-content');
topview.parentNode.insertBefore(iframe, topview)
我注入的 iframe.html
<div>
<p id="title">Tom Clancy</p>
</div>
我試圖操縱 iframe 的內容:
iframe.getElementById('title').innerHTML = "Harry Potter";
和
iframe.contentWindow.getElementById('title').innerHTML = "Harry Potter";
看起來好像您在https://brickseek.com托管此代碼。
然而,這行代碼:
chrome.extension.getURL ('iframe.html');
似乎將 iframe src 設置為類似“chrome-extension://id”的內容
(我對 Chrome 擴展沒有太多經驗,但它們似乎與這個問題並不特別相關。)
錯誤是說您不能 iframe 不同協議 (chrome-extension://) 的文檔到 iframe 出現的頁面 (https://)。 它們都必須是 https://
嘗試在同一台服務器上托管您的iframe.html
然后簡化您的代碼
iframe.src = "/iframe.html"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.