JS實現同時搜尋百度和必應的方法,js實現搜尋百度

來源:互聯網
上載者:User

JS實現同時搜尋百度和必應的方法,js實現搜尋百度

本文執行個體講述了JS實現同時搜尋百度和必應的方法。分享給大家供大家參考。具體如下:

這裡實現同時搜尋百度和必應的功能,輸入關鍵字,點擊“搜一下”按鈕,兩個搜尋引擎的結果在同個頁面開啟,方便。

將下面這兩個htm檔案儲存,放在同一個檔案夾下,開啟第一個檔案就可以了。
index.htm的代碼:
複製代碼 代碼如下:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>同時搜尋百度和必應</title>
<meta http-equiv="keywords" content="同時搜尋百度和必應">
<meta http-equiv="description" content="同時搜尋百度和必應">
</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>

第二個的檔案名稱為keleyi.htm

keleyi.htm的代碼如下:
複製代碼 代碼如下:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>同時搜尋百度和必應</title>

<meta http-equiv="keywords" content="同時搜尋百度和必應">
<meta http-equiv="description" content="同時搜尋百度和必應">

<!--<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");
//提交給百度,構造地址參數
oForm.action = "http://www.baidu.com/s";
okeyword.name = "wd";
oForm.method = "get";
oForm.target = "baiduFrame";
oForm.submit();
//提交給bing,構造地址參數
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="搜一下~" onclick="mixSearch();" />
</form>
<hr />

</body>
</html>

希望本文所述對大家的javascript程式設計有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.