'Wrong redirect on js
Hi im trying to make chrome extension and im stuck at point that script redicrect me to wrong site.
manifest.json
"name": "Popup ",
"manifest_version": 2,
"version": "0.1",
"description": "Search for something",
"browser_action": {
"default_icon": "questionn.png",
"default_popup": "popup.html"
},
"permissions": [
"tabs",
"http://*/*",
"https://*/*"
]
}
popup.html
<html>
<head>
<script src="popup.js"></script>
<style type="text/css" media="screen">
body {
min-width: 250px;
text-align: center;
}
#click-me {
font-size: 15px;
}
</style>
</head>
<body>
<input type="text" id="rest">
<button id='click-me'>Click Me! </button>
</body>
</html>
popup.js
function clickHandler(e) {
chrome.tabs.create({ url: "www.youtube.com/watch?v=" + document.getElementById('rest').value });
window.close(); // Note: window.close(), not this.close()
}
document.addEventListener('DOMContentLoaded', function () {
document.getElementById('click-me').addEventListener('click', clickHandler);
});
When I'm adding "cCoed5Oo_J4" in searchbox it redirects me to "chrome-extension://lldddgdjlmoagiokneclpnhbcamggdnf/www.youtube.com/watch?v=cCoed5Oo_J4" instead of correct site. Can you guys please help me on that?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
