日期:2014-05-17  浏览次数:20836 次

如何修改这段百度提供的代码
<SCRIPT   language=javascript>
function   g(formname) {
var   url   =   "http://www.baidu.com/baidu ";
if   (formname.s[1].checked)   {
formname.ct.value   =   "2097152 ";
}
else   {
formname.ct.value   =   "0 ";
}
formname.action   =   url;
return   true;
}
</SCRIPT>
<form   name= "f1 "   onsubmit= "return   g(this) ">
<table   bgcolor= "#FFFFFF "   style= "font-size:9pt; ">
<tr   height= "60 "> <td   valign= "top "> <img   src= "http://img.baidu.com/img/logo-137px.gif "   border= "0 "   alt= "baidu "> </td>
<td>
<input   name=word   size= "30 "   maxlength= "100 ">
<input   type= "submit "   value= "百度搜索 "> <br>
<input   name=tn   type=hidden   value= "bds ">
<input   name=cl   type=hidden   value= "3 ">
<input   name=ct   type=hidden>
<input   name=si   type=hidden   value= "www.guoxue.com ">
<input   name=s   type=radio>   互联网
<input   name=s   type=radio   checked>   www.guoxue.com
</td> </tr> </table>
</form>

当点击按钮就会搜索www.guoxue.com站点中的内容,我想点击后在一个新页面打开而不是像现在一样在原始界面打开.


------解决方案--------------------
<SCRIPT language=javascript>
function g(formname) {
var url = "http://www.baidu.com/baidu ";
if (formname.s[1].checked) {
formname.ct.value = "2097152 ";
}
else {
formname.ct.value = "0 ";
}
formname.action = url;
return true;
}
</SCRIPT>
<form name= "f1 " onsubmit= "return g(this) " target= "_blank ">
<table bgcolor= "#FFFFFF " style= "font-size:9pt; ">
<tr height= "60 "> <td valign= "top "> <img src= "http://img.baidu.com/img/logo-137px.gif " border= "0 " alt= "baidu "> </td>
<td>
<input name=word size= "30 " maxlength= "100 ">
<input type= "submit " value= "百度搜索 "> <br>
<input name=tn type=hidden value= "bds ">
<input name=cl type=hidden value= "3 ">
<input name=ct type=hidden>
<input name=si type=hidden value= "www.guoxue.com ">
<input name=s type=radio> 互联网
<input name=s type=radio checked> www.guoxue.com
</td> </tr> </table>
</form>


改动的地方: <form name= "f1 " onsubmit= "return g(this) " target= "_blank ">