JStoffell JStoffell - 1 year ago 110
HTML Question

Form does not open in new tab

this is the code I am using, I have specified target="_blank" in the form however it doesn't open in a new tab.

function process()
var url="https://website.com/search/" + document.getElementById("url").value;
return false;
<form action="https://website.com/search/" target="_blank" onSubmit="return process();">
Search: <input type="text" name="url" id="url"> <input type="submit" value="go">

Answer Source

The target is only used when the form is submitted normmally. You're preventing this by returning false from the onsubmit function.

Since process is redirecting to a new URL instead of submitting the form, you can instead open a new window/tabl there. So replace

locaiton.href = url;


window.open(url, "_blank");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download