Google Baidu
来源:互联网 发布:单片机与传感器 编辑:程序博客网 时间:2024/05/22 18:21
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> <title>MySearch</title> <script> function search(){ var obj = document.getElementById("keyword"); //alert(obj.value); //输入的数据 var i = document.getElementsByName("sa"); for (var j = 0; j < i.length; j++) { if (i[j].checked) { if (i[j].value == 1) { window.open("http://www.baidu.com/s?wd=" + obj.value); //跳出一个新页面 //window.location.href="http://www.baidu.com/s?wd="+obj.value; } else { window.open("http://www.google.com.hk/search?q=" + obj.value); //window.location.href="http://www.google.com.hk/search?q="+obj.value; } } } } </script> </head> <body> <input type="text" id="keyword"/><input type="button" value="Search" onclick="search()"/> <br/> <input type="radio" name="sa" checked="checked" value="1"/>Baidu<input type="radio" name="sa" value="2"/>Google </body></html>