この記事では、BaiduとBingを同時に検索するJSの方法について説明します。参照のためにそれを共有してください。詳細は次のとおりです。
ここでは、BaiduとBingを同時に検索する機能を認識し、キーワードを入力し、[検索]ボタンをクリックすると、2つの検索エンジンの結果が同じページで開かれます。これは便利です。
次の2つのHTMファイルを保存し、それらを同じフォルダーに配置し、最初のファイルを開きます。
index.htmのコード:
コードを次のようにコピーします。
<html>
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<Title> BaiduとBingを同時に検索</title>
<メタhttp-equiv = "keywords" content = "BaiduとBingを同時に検索">
<メタhttp-equiv = "description" content = "BaiduとBingを同時に検索">
</head>
<! - <body style = "text-align:center;">
- >
<フレームセット行= "30%、70%">
<frame src = "keleyi.htm">
</frame>
<フレームセット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>
2番目のファイル名はkeleyi.htmです
keleyi.htmのコードは次のとおりです。
コードを次のようにコピーします。
<html>
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<Title> BaiduとBingを同時に検索</title>
<メタhttp-equiv = "keywords" content = "BaiduとBingを同時に検索">
<メタhttp-equiv = "description" content = "BaiduとBingを同時に検索">
<! - <link rel = "styleSheet" type = "text/css" href = "./ styles.css"> - >
<script type = "text/javascript">
function $(id){
document.getElementByID(ID)を返します。
}
function mixsearch(){
var okeyword = $( "keyword");
var oform = $( "searchform");
//アドレスパラメーターを構築するためにBaiduに送信します
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"ターゲット= "baiduframe">
<入力型= "text" id = "keyword" name = "wd" value = "" />
<入力型= "button" value = "search〜" onclick = "mixsearch();" />
</form>
<hr />
</body>
</html>
この記事がみんなのJavaScriptプログラミングに役立つことを願っています。