JS实现同时搜索百度和必应的方法
JS实现同时搜索百度和必应的方法
发布时间:2016-12-30 来源:查字典编辑
摘要:本文实例讲述了JS实现同时搜索百度和必应的方法。分享给大家供大家参考。具体如下:这里实现同时搜索百度和必应的功能,输入关键字,点击“搜一下”...

本文实例讲述了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>

-->

<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="同时搜索百度和必应">

<>

<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>

<form action="" id="searchForm" method="get" target="baiduFrame">

<input type="text" id="keyword" name="wd" value="" />

<input type="button" value="搜一下~" />

</form>

<hr />

</body>

</html>

希望本文所述对大家的javascript程序设计有所帮助。

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类