![](/img/trans.png)
[英]Getting an iframe that's nested within another iframe chrome extension
[英]Content script isn't running in iframe within another extension's page
假設Google Chrome中安裝了2個擴展程序。
第一個擴展在w3.org上運行content.js:
manifest.json的:
"content_scripts": [{
"matches": [ "https://www.w3.org/*" ],
"all_frames": true,
"js": [ "content.js" ]
}]
content.js:
alert('content');
第二個擴展名有page.html,它將w3.org加載到iframe中:
manifest.json的:
"web_accessible_resources": ["page.html"]
page.html中:
<!DOCTYPE html>
<iframe src="https://www.w3.org/"></iframe>
現在輸入地址欄chrome-extension://2nd-extension-id/page.html
。 你會看到w3.com,但是content.js沒有運行(沒有alert()
窗口)。 我沒有在控制台中看到錯誤。
問題是:如何允許內容腳本在此iframe中運行?
我創建了Chrome問題 。 狀態:WontFix,不幸的是。 但是這可以在將來改變......
您不能使用擴展程序,但可以在Google Apps中執行類似操作:您可以使用webview而不是iframe。 因此,您可以通過executeScript
方法注入腳本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.