0

i just wrote simple chrome extension and just want to read the value of some element of special page using document.getElementById('ID') but it return NULL anyway ...

this is manifest.json

{
  "manifest_version": 2,
  "name": "GTmetrix Analyzer Plugin",
  "description": "This extension will analyze a page using GTmetrix",
  "version": "1.0",
  "browser_action": {
    "default_icon": "icon.png",
    "default_popup": "popup.html"
  },
  "permissions": [
    "https://www.example.com/*",
    "activeTab",
    "<all_urls>"
  ]
}

and this is popup.js

<!doctype html>
<html>
<head>
    <title>GTmetrix Analyzer</title>
    <script src="popup.js"></script>
</head>
<body>
<h1>GTmetrix Analyzer</h1>
<button id="checkPage">check page</button>
</body>
</html>

and popup.js file

document.addEventListener('DOMContentLoaded', function () {
    var checkPageButton = document.getElementById('checkPage');
    checkPageButton.addEventListener('click', function () {
        let PO_Number = document.getElementById('po_number')
        alert(PO_Number)
    }, false);
}, false);

whats wrong with me guys ... could you help me please ?

0 Answers0