欢迎来到代码驿站!

JavaScript代码

当前位置:首页 > 网页前端 > JavaScript代码

JS实现同时搜索百度和必应的方法

时间:2021-06-29 08:27:20|栏目:JavaScript代码|点击:

本文实例讲述了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程序设计有所帮助。

上一篇:分享JS代码实现鼠标放在输入框上输入框和图片同时更换样式

栏    目:JavaScript代码

下一篇:js实现无限级树形导航列表效果代码

本文标题:JS实现同时搜索百度和必应的方法

本文地址:http://www.codeinn.net/misctech/149806.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有