DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> JS實現一次搜索百度和必應
JS實現一次搜索百度和必應
編輯:關於JavaScript     
實現一次搜索百度和必應,輸入關鍵字,點擊“搜一下”按鈕,兩個搜索引擎的結果在同個頁面打開,方便。
點擊這裡查看效果:http:///keleyi/phtml/jstexiao/6.htm

將這兩個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="一次搜索百度和必應,,keleyi">
<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="http:///keleyi/phtml/jstexiao/6/keleyi.jpg"></frame>
<frame id="bingFrame" name="bingFrame" src="http:///keleyi/phtml/jstexiao/6/keleyi.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="一次搜索百度和必應,,keleyi">
<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;">一次搜索百度和必應·<a href="http:///a/bjac/06ysbxv0.htm" target="_blank">原文</a>
<form action="" id="searchForm" method="get" target="baiduFrame">
<input type="text" id="keyword" name="wd" value="site:" />
<input type="button" value="搜一下~" onclick="mixSearch();" />
</form>
<hr />

</body>
</html>
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved