示例演示:http://scboy.ik8.com/CallSearch.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>CallSearch</title>
<script language="javascript">
// 处理输入的字符串,用+号代替空格
function search()
{
var zfc = document.eingabe.searchtext.value;
var searchword = "";
for ( var i = 0; i < zfc.length; i++ )
{
// 获得一个字符
var char = zfc.substring( i, i+1 );
// 判断是否为空格
if ( char == " " )
{
searchword += "+"; // 连接一个加号
}
else
{
searchword += char; // 连接字符
}
}
// google搜索
if ( document.eingabe.google.checked == true )
{
var google = open( "http://www.google.com/search?q=" + searchword, "Google",
"toolbar=yes, menubar=yes, status=yes, driectories=yes, location=yes, scrollbars=yes, resizable=yes" );
}
// 百度搜索
if ( document.eingabe.baidu.checked == true )
{
var baidu = open( "http://www.baidu.com/s?wd=" + searchword, "百度",
"toolbar=yes, menubar=yes, status=yes, driectories=yes, location=yes, scrollbars=yes, resizable=yes" );
}
}
</script>
</head>
<body>
<form name="eingabe" onSubmit="search();return false;">
请输入要搜索的字符串:<br>
<input type="text" name="searchtext" size="30" value="">
<p>请选择使用的搜索引擎:</p><br>
<input type="checkbox" name="google" checked>Google
<input type="checkbox" name="baidu">百度
<p><input type="button" value="开始搜索" onClick="search()"></p>
</form>
</body>
</html>
评论