I have a google chrome extension that has popup which contains and iframe. The iframe points to a domain abc.com. Is there any way I can click in the iframe and send a message to the background script of my chrome extension. I tried adding the following javascript code to my index.php page on abc.com.
<script src="http://code.jquery.com/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("#mybtn").click(function(){
chrome.extension.sendMessage({ action: "new message" });
});
});
</script>
and in background.js
chrome.extension.onMessage.addListener(function(request,sender,sendResponse(){
if(request.action=="new message"){
alert ("Message Recieved");
}
});
But it does not work maybe I am missing something. Please help.