如何将搜索的内联脚本移动到单独的 js 文件中?
How can I move the inline scripts for my search out into a separate js file?
我的页面上有一个搜索栏,但我需要将代码移出到一个单独的 js 文件中,以便将所有内容作为 google 浏览器扩展提交。现在HTML:
里面是这样写的
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search</title>
<link rel="stylesheet" type="text/css" href="popup.css" />
</head>
<body>
<div id="searchContainer">
<script type="text/javascript">
function dos12(g1) {
window.open('https://www.google.com/#q=' + g1, '_self', 'G1window');
}
</script>
<form onsubmit="dos12(this.g1.value); return false;">
<input id="field" type="text" name="g1" size="20" placeholder="Google Search" autofocus="autofocus" />
<div id="delete"><span id="x">x</span></div>
<input id="submit" name="submit" type="submit" value="Search" />
</form>
</div>
</body>
</html>
我已将其他脚本移出 HTML 并放入 js 文件中,并将
我的页面上有一个搜索栏,但我需要将代码移出到一个单独的 js 文件中,以便将所有内容作为 google 浏览器扩展提交。现在HTML:
里面是这样写的<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search</title>
<link rel="stylesheet" type="text/css" href="popup.css" />
</head>
<body>
<div id="searchContainer">
<script type="text/javascript">
function dos12(g1) {
window.open('https://www.google.com/#q=' + g1, '_self', 'G1window');
}
</script>
<form onsubmit="dos12(this.g1.value); return false;">
<input id="field" type="text" name="g1" size="20" placeholder="Google Search" autofocus="autofocus" />
<div id="delete"><span id="x">x</span></div>
<input id="submit" name="submit" type="submit" value="Search" />
</form>
</div>
</body>
</html>
我已将其他脚本移出 HTML 并放入 js 文件中,并将