I want to use the function document.write in order to write something in the popup.html of a chrome.extension and I cant get it working. Have been crawling google for hours but still stuck.
popup.html
<!DOCTYPE html>
<html>
<head><meta charset="utf-8">
</head>
<body>
<div id ="master">
</div>
</body></html>
manifest.json
{
"manifest_version": 2,
"name": "Example",
"description": "Description",
"version": "1.0",
"browser_action":
{
"default_icon": "icon.png",
"default_popup": "popup.html",
"default_title": "myweb.com"
},
"background":
{
"scripts": [ "background.js" ],
"persistent": true
},
"permissions": [
"activeTab",
"alarms",
"storage",
"notifications",
"tabs"
]
}
here the code that causes problem in background.js:
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
document.master.write( '<iframe src="http://www.xxxx.com/someaction" ' +
'style="padding:0px; overflow:hidden;" '+
'width="400px" height="350px"></iframe>' );
...///...
Error triggered:
Error in event handler for tabs.onUpdated: TypeError: Cannot read property 'write' of undefined
Thanks for your help !