问题描述
Problem: to open a new window with the select -option
=return handleSubmit()target =_ blankmethod =getname =moduleFormid =moduleForm>
< font size = 2 face = verdana color =#0000ff>< b>搜寻< / b>< / font>
< optgroup label =历史>
< option value =http://www.something.com/cse?cx=0000000000000&sa=Search&q=>在新窗口中打开1< / option>
< option value =http://www.google.com/cse?cx=0000000000000000A-cmjrngmyku&ie=UTF-8&sa=Search&q=>在新窗口中打开2< /选项>
< / optgroup>
< / select>
< input type =textname =allQueryid =allQuerysize =22/>
< input type =submitvalue =Go/>
<form onsubmit="return handleSubmit()" target="_blank" method="get" name="moduleForm" id="moduleForm"><font size=2 face = verdana color= #0000ff ><b>Search</b></font> <select name="allSelect" id="allSelect"> <optgroup label="Historical"> <option value="http://www.something.com/cse?cx=0000000000000&sa=Search&q=">Open in a new window 1</option> <option value="http://www.google.com/cse?cx=0000000000000000A-cmjrngmyku&ie=UTF-8&sa=Search&q=">Open in a new window 2</option> </optgroup> </select><input type="text" name="allQuery" id="allQuery" size="22" /><input type="submit" value=" Go " />
问题:如何将内容打开到新窗口选择框?
Question: How can I open the content to a new window with a select-box?
推荐答案
修改如下:
Modify your handleSubmit
function as follows:
function handleSubmit()
{
var form = _gel("moduleForm"),
elm = _gel("allQuery"),
selectElm = _gel("allSelect");
if (elm != "" && selectElm != "") {
var query = elm.value;
var searchUrl = selectElm.value;
if (query != "" && searchUrl != "") {
searchUrl += escape(query);
window.open(searchUrl, form.target || "_blank");
}
}
return false;
}
这篇关于HTML:target =" _blank"为一个下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!