gpt4 book ai didi

javascript - iframe 中的 chrome 扩展允许同源被阻止

转载 作者:行者123 更新时间:2023-11-27 23:36:21 28 4
gpt4 key购买 nike

list .json

 {
"manifest_version": 2,
"name": "Test iframe",
"version": "1.0",
"content_scripts": [ {
"all_frames": true,
"js": [ "script.js" ],
"match_about_blank": true,
"matches": [ "\u003Call_urls>" ],
"run_at": "document_start"
} ],
"permissions": ["\u003Call_urls>"]
}

脚本.js

var s = document.createElement("script");
var str='console.log(1);';
s.type = "text/javascript";
s.text = str, document.documentElement.insertBefore(s, null);

测试:jsbin.com

错误:阻止“about:blank”中的脚本执行,因为文档的框架已沙箱化且未设置“allow-scripts”权限。

如何访问沙箱 iframe?

chrome.exe --disable-web-security -不工作。

最佳答案

您必须在 iframe 的沙箱属性中添加“允许脚本”

关于javascript - iframe 中的 chrome 扩展允许同源被阻止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34107118/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com