I'm developing extension for browsers and i have a problem with Google Chrome.
In manifest.json file i have declared default_popup page and in that page i have a button which will change window.location.href on click. The problem is when i click that button, popup page is not changing. How can i achieve that on Google Chrome? On Firefox is working well.
Here is the code
manifest.json
"manifest_version": 2,
"name": "NewExt",
"version": "1.0",
"description": "My best project",
"icons": {
"48": "icons/icon-48.png"
},
"browser_action": {
"browser_style": true,
"default_popup": "popup.html",
"default_icon": {
"48": "icons/icon-48.png"
}
}
}
popup.html
<!DOCTYPE html>
<html>
<head> </head>
<body>
<button id="btn">Click</button>
<script src="main.js" type="text/javascript"></script>
</body>
</html>
main.js
function redirect() {
window.location.href = "http://example.org";
console.log("works");
}
document.getElementById("btn").addEventListener("click", function () {
redirect();
});
question from:
https://stackoverflow.com/questions/65938652/chrome-extension-poup-window-location-change 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…