1
我正在開發一個Chrome擴展,我希望它將iframe插入Google主頁,但該html只顯示爲純文本。爲什麼會發生?當插入到網頁時,HTML顯示爲純文本
這是目前我的代碼:
manifest.json的
{
"manifest_version": 2,
"name": "Google",
"version": "1.0",
"description": "Google iframe",
"icons": {
"48": "img/rsz_apple-touch-icon-144x144.png",
"16": "img/favicon-16x16.png",
"128": "img/rsz_1apple-touch-icon-144x144.png"
},
"content_scripts": [{
"matches": ["https://www.google.com.au/"],
"js": ["content-script.js"]
}],
"browser_action": {
"default_icon": "img/favicon-16x16.png",
"default_title": "Press the button to see more actions",
"default_popup": "popup.html"
},
"background": {
"page": "background.html"
},
"permissions": [
"activeTab"
]
}
內容的script.js
var div=document.createElement("div");
document.getElementById("searchform").appendChild(div);
div.innerText="<iframe src='https://www.google.com.au/'>ERROR</iframe>";
謝謝你的幫助。