Google chrome 在chrome扩展中加载iframe后修改弹出窗口
我想修改chrome扩展的popup.html。我加载一个iFrame,其中包含一个外部URL。加载iFrame后,我想修改popup.html中的div标记 popup.htmlGoogle chrome 在chrome扩展中加载iframe后修改弹出窗口,google-chrome,google-chrome-extension,Google Chrome,Google Chrome Extension,我想修改chrome扩展的popup.html。我加载一个iFrame,其中包含一个外部URL。加载iFrame后,我想修改popup.html中的div标记 popup.html <head> <script type = "text/javascript" src = "popup.js"></script> </head> <body> <form name = "getPage" action = "ht
<head>
<script type = "text/javascript" src = "popup.js"></script>
</head>
<body>
<form name = "getPage" action = "http://website.com/" method = "post" target = "post_stuff">
<input type = "hidden" name = "hdnrequesttype" value = "1" />
<input type = "hidden" name = "txtmemberid" id = "txtmemberid" value = "11012333" />
<input type = "hidden" name = "txtmemberpwd" id = "txtmemberpwd" value = "" />
<input type = "hidden" name = "sites" value = "0" />
<input type = "hidden" name = "firsttime" value = "Y" />
</form>
<iframe name = "post_stuff" height = "600" width = "600" onload = "frame_loaded()">
</iframe>
<div id = "putText">
</div>
</body>
这不起作用。我试着使用内容脚本,但效果不太好。我的内容脚本modify.js的内容:-
modify.js
window.onload = function() {
document.forms["getPage"].submit();
}
function frame_loaded() {
document.getElementById("putText").innerHTML = "LOADED";
console.log("LOADED");
}
document.getElementById("putText").innerHTML = "LOADED";
以下是我的舱单的相关部分:-
"content_scripts" : [ {
"matches": ["<all_urls>"],
"js": ["modify.js"]
}
]
“内容脚本”:[{
“匹配项”:[“”],
“js”:[“modify.js”]
}
]
我希望有人能帮我解决这个问题。我猜你正在使用
清单\u版本:2
。如果是这样,则需要使用addEventListener
而不是内联onload
处理程序:
window.onload = function() {
//attach a load listener to the iframe
document.querySelector("iframe").addEventListener("load", frame_loaded);
document.forms["getPage"].submit();
}
您是否正在使用清单版本:2?版本2下不允许内联
onload
处理程序。我正在使用manifest\u版本:2