Good day. I get acquainted with the creation of chrom extensions and faced with a lack of understanding of the principle of extensions. Task: By clicking on the button with id = "btn" pull the text out of the block with id = "content" For the test there is a simple html page:
<html> <head> </head> <body> <div id="content">Text</div> </body> </html> Here is the manifest itself:
{ "manifest_version": 2, "name": "test", "version": "1.0", "description": "Just a simle extension", "permissions": [ "tabs", "activeTab" ], "content_scripts": [ { "matches": [ "*://*/*" ], "js": [ "popup.js" ], "css": [ "style.css" ], "run_at": "document_start" } ], "browser_action": { "default_title": "test", "default_icon": "ico/icon.png", "default_popup": "popup.html" }, "options_page": "options.html" } Here's the code for popup.js:
window.onload = function () { var get = function (id) { return document.getElementById(id); } get("btn").onclick = function () { var txt = document.getElementById("content"); alert(txt.innerHTML); } } Please explain why it does not work. Thank you in advance.