javascript - Chrome Extension: Interacting with iframe embedded within popup -
i writing chrome extension needs interact urls user not have open. therefore using hidden iframes embedded within popup, , attempting click button within iframe. however, receiving same origin policy error. know possible extension interact iframes of different domain via content scripts when iframe on tab user has open, not sure if possible use content scripts interact iframes directly in popup.
here code:
manifest.json
"content_scripts": [ { "js": [ "bin/jquery.min.js", "interaction.js" ], "all_frames": true, "run_at": "document_start", "matches": [ "http://*/*", "https://*/*" ] }], "permissions": [ "activetab", "tabs", "http://*/", "https://*/" ],
interaction.js
$(document).ready(function() { $('div#iframes').append("<iframe id='shop' src='https://www.google.com/'></iframe>") $('iframe').bind("load", function() { $('iframe').contents().find("html").ready(function() { loadedstores += 1; if (loadedstores == carts.totalstores) { $('div#cost').append(carts.grandtotal) showmain(); } }) }) })
error
uncaught securityerror: blocked frame origin "chrome-extension://mapgjiofchdchalgcifmdolgcekfaadp" accessing frame origin "https://www.google.com/". frame requesting access has protocol of "chrome-extension", frame being accessed has protocol of "http". protocols must match.
the error occurs in interaction.js in third line (with load callback). know changes should make content script allow me interact iframe? or if there other approaches should take? thanks!
your frame have content script injected.
you need communicate content script using messaging , make need.
here's further information:
Comments
Post a Comment