我正在尝试使用下面的代码来制作一个简单的 chrome 扩展、输入文本和一个按钮,并且在单击按钮时,我想提取一个特定的 URL。我在编写代码时遇到问题。我对 JavaScript 相当陌生。
<!doctype html>
<html>
<head>
<title>Title Name</title>
<style>
body {
min-width: 357px;
overflow-x: hidden;
}
img {
margin: 5px;
border: 2px solid black;
vertical-align: middle;
width: 75px;
height: 75px;
}
</style>
</head>
<body>
<input type="text" name="enter" class="enter" value="67" id="lolz" />
<button type="button" id="the_button">LookUp Site ID</button>
<script src="popup.js"></script>
</body>
</html>
popup.js - 更新
var VanillaRunOnDomReady = function() {
document.getElementById('the_button').addEventListener('click', myFunction);
function myFunction() {
var siteid = document.getElementById('lolz').value
//window.location = "https://www.websiteimusing.com/siteid" + siteid;
chrome.tabs.create({ url: "https://www.websiteimusing.com/siteid" + siteid});
}
}
}
清单.json
{
"manifest_version": 2,
"name": "ID URL opener",
"description": "Enter ID and it will pull up the correct URL",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": ["tabs"]
}
当前错误 - 更新
它没有填充错误,只是在单击按钮时从未实际加载 URL,有什么想法吗?