JS implements the method of searching Baidu and Bing at the same time, and js implements Baidu search
This article describes how to search Baidu and Bing simultaneously using JS. Share it with you for your reference. The details are as follows:
Here, you can search for Baidu and Bing at the same time. Enter the keyword and click "Search". The results of the two search engines are displayed on the same page for convenience.
Save the following two htm files in the same folder and open the first file.
Code for index.htm:
Copy codeThe Code is 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 Baidu and Bing at the same time </title>
<Meta http-equiv = "keywords" content = "Search Baidu and Bing">
<Meta http-equiv = "description" content = "Search Baidu and Bing">
</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" width = "49%" height = "100%"> </iframe>
<Iframe id = "bingFrame" width = "49%" height = "100%"> </iframe>
</Body> -->
</Html>
The second file is named keleyi.htm.
The keleyi.htm code is as follows:
Copy codeThe Code is 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 Baidu and Bing at the same time </title>
<Meta http-equiv = "keywords" content = "Search Baidu and Bing">
<Meta http-equiv = "description" content = "Search 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 it to Baidu to construct address parameters
OForm. action = "http://www.baidu.com/s ";
Okeyword. name = "wd ";
OForm. method = "get ";
OForm.tar get = "baiduFrame ";
OForm. submit ();
// Submit it to bing to construct address parameters
OForm. action = "http://hk.bing.com/search ";
Okeyword. name = "q ";
OForm. method = "get ";
OForm.tar get = "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 help you design javascript programs.