<script>
function process()
{
var url="http://google.com/?hl=en&q=" + document.getElementById("query").value;
location.href=url;
return false;
}
</script>
<form onSubmit="return process();" target="_blank">
query: <input type="text" name="query" id="query">
<input type="submit" value="go">
</form>
如何在新标签上处理此内容?
答案 0 :(得分:2)
你可以写 -
function process() {
var url="http://google.com/?hl=en&q=" + document.getElementById("query").value;
window.open(url, '_blank');
return false;
}
答案 1 :(得分:0)
放置window.open(url,“_ blank”)而不是location.href = url;
<script>
function process()
{
var url="http://google.com/?hl=en&q=" + document.getElementById("query").value;
window.open(url,"_blank");
return false;
}