0

Right now it only opens in the same window, I want it to open in a new window upon submisson.

Here's what's in the head:

<script type="text/javascript"> 
function getURL(val){ 
base = 'http://www.domain.com/'; 
location = base + val; 
return false; 
} 
</script> 

Here's the what's in the body:

<form id="form1" name="form1" method="post" action="" onsubmit="return getURL(this.url.value)"> 
<label> 
<input type="text" name="url" /> 
</label> 
<label> 
<input type="submit" name="Submit" value="Submit" /> 
</label> 
</form> 
  • um, window.open() or just set the target and action. – epascarello Jun 25 '14 at 16:58
  • possible duplicate of [How to open a new window on form submit](http://stackoverflow.com/questions/896724/how-to-open-a-new-window-on-form-submit) – JJJ Jun 25 '14 at 16:58
  • please search through previous answered questions before asking http://stackoverflow.com/questions/1574008/how-to-simulate-target-blank-in-javascript – luchosrock Jun 25 '14 at 16:58

2 Answers2

0
<form target="_blank" ...></form>

Further reading:

When to use target = _blank

ohboy21
  • 4,259
  • 8
  • 38
  • 66
  • Not going to work....It will submit the form to a new window, but not take them to the location they are after. – epascarello Jun 25 '14 at 16:59
  • 1
    Why? It is in the [documentation](http://www.w3schools.com/tags/att_form_target.asp): "_Display the response received in a new window or tab_". – blex Jun 25 '14 at 17:00
0

If you want to do it in javascript, but it may get blocked by a popup blocker.

window.open(location);
jgreenberg
  • 478
  • 1
  • 4
  • 17