I'm appending an iframe
to a page using content script
with src
set to chrome.extension.getURL(myPage)
. Later on some event, I want to retrieve some element from the frame. I tried the following code in content script
:
var textFrame = document.getElementById('iframeId');
var text = (textFrame.contentDocument || textFrame.contentWindow.document).getElementById('someDivId');
but it throws the following error:
Unsafe JavaScript attempt to access frame with URL chrome-extension://ipkjfhkdgodpcgpjepdjhcbfcbbbcpee/TopBar.html from frame with URL http://theInjectedPage.com/xxx/xxx/xxx. Domains, protocols and ports must match.
In manifest
file all_frames
is set to true
.
Please help me to resolve this.
Update: Here is a part of my manifest file:
"permissions": [
"tabs",
"chrome://favicon/",
"http://*/*",
"https://*/*"
],
"background": {
"scripts": ["Javascript/background.js"]
},
"content_scripts": [
{
"matches": ["http://*/*"],
"js": ["Javascript/References/jquery-1.7.min.js","Javascript/content_script.js"],
"run_at": "document_start",
"all_frames": true
}
],
"web_accessible_resources": ["TopBar.html","Javascript/TopBar.js","Javascript/References/jquery-1.7.min.js"]