This article describes the JS implementation of both Baidu and Bing search methods. Share to everyone for your reference. Specifically as follows:
Here to achieve simultaneous search Baidu and Bing function, input keywords, click the "Search" button, two search engine results on the same page open, convenient.
Save the following two HTM files in the same folder and open the first file.
Code for index.htm:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title> search both Baidu and Bing </title>
<meta http-equiv= "keywords" content= "search both Baidu and Bing" >
<meta http-equiv= "description" content= "search both Baidu and Bing" >
<!--<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" width= "49%" height= "100%" ></iframe>
<iframe id= "Bingframe" width= "49%" height= "100%" ></iframe>
</body>-->
The second file name is keleyi.htm
The code for keleyi.htm is as follows:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">
<title> search both Baidu and Bing </title>
<meta http-equiv= "keywords" content= "search both Baidu and Bing" >
<meta http-equiv= "description" content= "search both Baidu and Bing" >
<!--<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, 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>
<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>
</body>
I hope this article will help you with your JavaScript programming.