我的网页如下:
<body>
<div class="row">
<button type="button" class="btn btn-primary" id="manual-dial" onclick="dial()";>DIAL</button>
</div>
</body>
/* the dial() function is written in js of parent web page */
content.js如下:
var phone=document.getElementById("manual-dial");
phone.addEventListener("click",dial, false);/*want to call dial function of webpage*/
chrome.runtime.sendMessage(/*send response from dial() to background.js*/);
background.js
chrome.runtime.onMessage.addListener(function(response,sender,sendResponse) {
alert(response);
});
我想从扩展程序调用我的网页的dial()函数。我怎样才能做到这一点 ?