【发布时间】:2016-04-26 08:09:47
【问题描述】:
我在网页上加载了 iframe。是否可以从扩展程序调用父网页的 iframe 中的函数?
已经在 manifest.json 中完成了 all-frames:true
iframe.html如下:
<body>
<div class="row">
<button type="button" class="btn btn-primary" id="manual-dial" onclick="dial()";>DIAL</button>
</div>
</body>
content.js如下:
/* cnt access frame id */
chrome.runtime.sendMessage(window.parent.frames[1].document.id);
window.parent.frames[1].document.id.onload = function() {
// want to call dial() of iframe
chrome.runtime.sendMessage("this is my response");
}
background.js
chrome.runtime.onMessage.addListener(function(response,sender,sendResponse) {
alert(response);
});
【问题讨论】:
标签: javascript jquery html google-chrome iframe