html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>选择搜索引擎进行搜索</title>
<script>
function searchSelectedEngine() {
var keyword = document.getElementById('keyword').value;
var engine = document.getElementById('engine').value;
var encodedKeyword = encodeURIComponent(keyword);
var searchUrl;
switch (engine) {
case 'bing':
searchUrl = "https://www.bing.com/search?q=" + encodedKeyword;
break;
case 'baidu':
searchUrl = "https://www.baidu.com/s?wd=" + encodedKeyword;
break;
case 'sogou':
searchUrl = "https://www.sogou.com/web?query=" + encodedKeyword;
break;
case 'so':
searchUrl = "https://www.so.com/s?q=" + encodedKeyword;
break;
default:
alert("请选择一个搜索引擎。");
return;
}
window.open(searchUrl, "_blank");
}
</script>
</head>
<body>
<h1>选择搜索引擎进行搜索</h1>
<label for="keyword">输入关键词:</label>
<input type="text" id="keyword" required>
<label for="engine">选择搜索引擎:</label>
<select id="engine">
<option value="bing">Bing</option>
<option value="baidu">Baidu</option>
<option value="sogou">Sogou</option>
<option value="so">So.com</option>
</select>
<button onclick="searchSelectedEngine()">搜索</button>
</body>
</html>