This article describes the method of JS to search for Baidu and Bing at the same time. Share it for your reference. The details are as follows:
Here we realize the function of searching for Baidu and Bing at the same time, enter keywords, click the "Search" button, and the results of the two search engines will be opened on the same page, which is convenient.
Save the following two htm files, place them in the same folder, and open the first file.
Code for index.htm:
Copy the code as follows:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Search for Baidu and Bing at the same time</title>
<meta http-equiv="keywords" content="Search for Baidu and Bing at the same time">
<meta http-equiv="description" content="Search for Baidu and Bing at the same time">
</head>
<!--<body style="text-align: center;">
-->
<frameset rows="30%,70%">
<frame src="keleyi.htm">
</frame>
<frameset cols="45%,45%">
<frame id="baiduFrame" name="baiduFrame" src="images/baidu.jpg"></frame>
<frame id="bingFrame" name="bingFrame" src="images/baidu.jpg"></frame>
</frameset>
</frameset>
<!--<iframe id="baiduFrame" ></iframe>
<iframe id="bingFrame" ></iframe>
</body>-->
</html>
The second file name is keleyi.htm
The code of keleyi.htm is as follows:
Copy the code as follows:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Search for Baidu and Bing at the same time</title>
<meta http-equiv="keywords" content="Search for Baidu and Bing at the same time">
<meta http-equiv="description" content="Search for Baidu and Bing at the same time">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
<script type="text/javascript">
function $(id) {
return document.getElementById(id);
}
function mixSearch() {
var okeyword = $("keyword");
var oForm = $("searchForm");
//Submit to Baidu to construct address parameters
oForm.action = "http://www.baidu.com/s";
okeyword.name = "wd";
oForm.method = "get";
oForm.target = "baiduFrame";
oForm.submit();
//Submit to bing, construct address parameters
oForm.action = "http://hk.bing.com/search";
okeyword.name = "q";
oForm.method = "get";
oForm.target = "bingFrame";
oForm.submit();
}
</script>
</head>
<body style="text-align: center;">
<form action="" id="searchForm" method="get" target="baiduFrame">
<input type="text" id="keyword" name="wd" value="" />
<input type="button" value="Search~" onclick="mixSearch();" />
</form>
<hr />
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.