AremaJancok
AremaJancok

Reputation: 1

how to open new tab on form onSubmit="return process();"

<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>

How to process this on new tab?

Upvotes: 0

Views: 1289

Answers (2)

chandu
chandu

Reputation: 2276

place window.open(url,"_blank") insted of location.href=url;

<script>
function process()
{
var url="http://google.com/?hl=en&q=" + document.getElementById("query").value;
window.open(url,"_blank");
return false;
}

Upvotes: 0

Prabhat Jain
Prabhat Jain

Reputation: 346

you can write -

function process() {
    var url="http://google.com/?hl=en&q=" + document.getElementById("query").value;
    window.open(url, '_blank');
    return false;
}

Upvotes: 2

Related Questions