以下是一个带有选项卡功能的搜索框代码,怎么修改为 [搜索时新窗口打开搜索页面] ?谢谢。
<SCRIPT language=JavaScript>
function sch(form){
e=document.sel.sq.selectedIndex; //取选定选项的编号
e=document.sel.sq[e].value; //取选定选项的"value"特征值
k=document.sel.k.value; //取搜索关键字
if(document.sel.k.value==""){ //如果没有填入关键字
alert("请输入关键词!"); //则给出提示
document.sel.k.focus(); //将光标移到输入框
return
}
//以下根据选择的内容改变 window.location 属性,进行本窗口导航
if(e=="baidu"){location="https://www.baidu.com/s?&wd="+k;}
if(e=="google"){location="https://www.baiduyaowan.com/webhp?gws_rd=ssl#q="+k;}
if(e=="so"){location="https://www.so.com/s?q="+k;}
if(e=="sogou"){location="https://www.sogou.com/web?query="+k;}
if(e=="bing"){location="http://cn.bing.com/search?q="+k;}
if(e=="zhihu"){location="https://www.zhihu.com/search?type=question&q="+k;}
if(e=="soku"){location="http://www.soku.com/v?keyword="+k;}
if(e=="tmall"){location="https://list.tmall.com/search_product.htm?q="+k;}
if(e=="taobao"){location="https://s.taobao.com/search?q="+k;}
if(e=="jd"){location="http://search.jd.com/Search?keyword="+k;}
if(e=="excite"){location="http://search.excite.com/search.gw?search="+k;}
}
</SCRIPT>
<form action=javascript:sch(this.form) method=post name=sel>
<table bgcolor=#c0c0c0 border=1 bordercolordark=#ffffff bordercolorlight=#000000 cellpadding=2 cellspacing=0 width="400" bordercolor="#FFFFFF" height="52">
<tbody>
<tr>
<td width="34%" align="center" height="32">
<font style="FONT-SIZE: 9pt">
<select name=sq size=1 tabindex=1>
<option selected value=baidu>百度</option>
<option value=google>谷歌</option>
<option value=so>好搜</option>
<option value=sogou>搜狗</option>
<option value=bing>必应</option>
<option value=zhihu>知乎</option>
<option value=soku>搜酷</option>
<option value=jd>京东</option>
<option value=tmall>天猫</option>
<option value=taobao>淘宝</option>
</select>
</font>
</td>
<td width="33%" align="center" height="32">
<input name=k size=14 tabindex=2>
</td>
<td width="33%" align="center" height="32">
<input name=search tabindex=3 type=submit value='开始搜索'>
</td>
</tr>
</tbody>
</table>
</form>
1
andy12530 2016-02-15 14:24:10 +08:00
window.open()
中间不能有任何异步的动作,不然会被浏览器阻挡。 |
2
FrankFang128 2016-02-15 14:25:22 +08:00
https://developer.mozilla.org/en-US/docs/Web/API/Window/open
window.open('http://xxx','_blank') |
3
edisonator 2016-02-15 14:26:13 +08:00
@FrankFang128 第二个参数加与不加有何区别
|
4
FrankFang128 2016-02-15 14:27:03 +08:00
跟 <a> 和 <a target="_blank"> 一样
|
5
FrankFang128 2016-02-15 14:29:00 +08:00
@edisonator 楼上
|
6
edisonator 2016-02-15 14:47:37 +08:00
@FrankFang128 不加参数不也是打开新窗口么?但是<a>不带 target 是直接跳转呀
|
7
FrankFang128 2016-02-15 17:47:56 +08:00 via Android
@edisonator 哦对,加了比较好
|