Este artículo describe el método de JS para buscar a Baidu y Bing al mismo tiempo. Compártelo para su referencia. Los detalles son los siguientes:
Aquí nos damos cuenta de la función de buscar a Baidu y Bing al mismo tiempo, ingresar a las palabras clave, hacer clic en el botón "Buscar" y los resultados de los dos motores de búsqueda se abrirán en la misma página, lo cual es conveniente.
Guarde los siguientes dos archivos HTM, colóquelos en la misma carpeta y abra el primer archivo.
Código para index.htm:
Copie el código de la siguiente manera: <
<html>
<Evista>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<title> Buscar a Baidu y Bing al mismo tiempo </title>
<meta http-oquiv = "palabras clave" content = "Buscar Baidu y Bing al mismo tiempo">
<meta http-oquiv = "descripción" content = "Buscar Baidu y Bing al mismo tiempo">
</ablo>
<!-<body style = "text-align: centro;">
->
<frameset filas = "30%, 70%">
<Frame src = "keleyi.htm">
</rame>
<frameset cols = "45%, 45%">
<Frame id = "Baidufame" name = "Baidufame" src = "Images/Baidu.jpg"> </Frame>
<Frame id = "bingframe" name = "bingFrame" src = "imágenes/baidu.jpg"> </rame>
</Frameset>
</Frameset>
<!-<iframe id = "Baidufame"> </iframe>
<iframe id = "bingframe"> </iframe>
</body>->
</html>
El segundo nombre del archivo es keleyi.htm
El código de keleyi.htm es el siguiente:
Copie el código de la siguiente manera: <
<html>
<Evista>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<title> Buscar a Baidu y Bing al mismo tiempo </title>
<meta http-oquiv = "palabras clave" content = "Buscar Baidu y Bing al mismo tiempo">
<meta http-oquiv = "descripción" content = "Buscar Baidu y Bing al mismo tiempo">
<!-<link rel = "stylesheet" type = "text/css" href = "./ styles.css">->
<script type = "text/javaScript">
función $ (id) {
return document.getElementById (id);
}
función mixSearch () {
var okeyword = $ ("palabra clave");
var oform = $ ("SearchForm");
// Enviar a Baidu para construir parámetros de dirección
oform.action = "http://www.baidu.com/s";
Okeyword.name = "wd";
oform.method = "get";
oform.target = "baidufame";
oform.submit ();
// Enviar a Bing, construir parámetros de dirección
oform.action = "http://hk.bing.com/search";
Okeyword.name = "Q";
oform.method = "get";
oform.target = "bingframe";
oform.submit ();
}
</script>
</ablo>
<Body style = "text-align: center;">
<Form Action = "" id = "SearchForm" Method = "Get" Target = "BaidUrFrame">
<input type = "text" id = "palabra clave" name = "wd" value = "" />
<input type = "Button" value = "search ~" onClick = "mixSearch ();" />
</form>
<hr />
</body>
</html>
Espero que este artículo sea útil para la programación de JavaScript de todos.