Este artigo descreve o método do JS para procurar Baidu e Bing ao mesmo tempo. Compartilhe para sua referência. Os detalhes são os seguintes:
Aqui, percebemos a função de procurar Baidu e Bing ao mesmo tempo, inserir palavras -chave, clicar no botão "Pesquisar" e os resultados dos dois mecanismos de pesquisa serão abertos na mesma página, o que é conveniente.
Salve os dois arquivos HTM a seguir, coloque -os na mesma pasta e abra o primeiro arquivo.
Código para index.htm:
Copie o código da seguinte forma: <!
<html>
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<title> Pesquise Baidu e Bing ao mesmo tempo </title>
<meta http-equiv = "palavras-chave" content = "Pesquise Baidu e Bing ao mesmo tempo">
<meta http-equiv = "description" content = "pesquise Baidu e Bing ao mesmo tempo">
</head>
<!-<body style = "text-align: Center;">
->
<FrameSet linhas = "30%, 70%">
<quadro src = "keleyi.htm">
</frame>
<FrameSet cols = "45%, 45%">
<quadro id = "Baiduframe" name = "Baiduframe" src = "Images/Baidu.jpg"> </frame>
<quadro id = "bingframe" name = "bingframe" src = "imagens/baidu.jpg"> </frame>
</frameSet>
</frameSet>
<!-<iframe id = "Baiduframe"> </frame>
<iframe id = "bingframe"> </frame>
</body>->
</html>
O segundo nome do arquivo é Keleyi.htm
O código de Keleyi.htm é o seguinte:
Copie o código da seguinte forma: <!
<html>
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<title> Pesquise Baidu e Bing ao mesmo tempo </title>
<meta http-equiv = "palavras-chave" content = "Pesquise Baidu e Bing ao mesmo tempo">
<meta http-equiv = "description" content = "pesquise Baidu e Bing ao mesmo tempo">
<!-<link rel = "stylesheet" type = "text/css" href = "./ styles.css">->
<script type = "text/javascript">
função $ (id) {
retornar document.getElementById (id);
}
function mixsearch () {
var oKeyword = $ ("palavra -chave");
var oform = $ ("searchform");
// Envie ao Baidu para construir parâmetros de endereço
OFORM.ACTION = "http://www.baidu.com/s";
OKEYWORD.NAME = "WD";
OFORM.METHOD = "GET";
OFORM.TARGET = "BAIDUFRAME";
OFORM.SUBMIT ();
// Envie ao Bing, construa parâmetros de endereço
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 ação = "" id = "searchform" método = "get" target = "Baiduframe">>
<input type = "text" id = "palavra -chave" name = "wd" value = "" />
<input type = "botão" value = "pesquisa ~" onclick = "mixsearch ();" />
</morm>
<hr />
</body>
</html>
Espero que este artigo seja útil para a programação JavaScript de todos.