0

I would like to open a page in a new tab, using target="blank". Where would I put that?

<head>
<script type="text/javascript">
<!--
function gotoURL() {
var newURL = ("http://tulyita.hu/pr2info.php?name=" + document.url2go.go.value)
document.location.href=newURL
}
//-->
</script>
</head>
<pre><center>

<form action="javaScript:gotoURL()" method="get" name="url2go">
<input type="text" name="go" value="" size="50">
<input type="submit" value="Ok">
</form>

<title>PR2 Checker GIF</title>
</center></body>
Ry-
  • 218,210
  • 55
  • 464
  • 476
Kárpáti András
  • 1,221
  • 1
  • 16
  • 35
  • possible duplicate of [Open a URL in a new tab using JavaScript](http://stackoverflow.com/questions/4907843/open-a-url-in-a-new-tab-using-javascript) –  Apr 30 '14 at 07:29
  • or inline target="_blank" – noobninja Apr 18 '15 at 23:17

3 Answers3

2

Try using this in your JavaScript function:

window.open("http://tulyita.hu/pr2info.php?name=" + document.url2go.go.value, "_blank");
Ry-
  • 218,210
  • 55
  • 464
  • 476
Raghu
  • 2,543
  • 1
  • 19
  • 24
1

Try this:-

<form action="javaScript:gotoURL()" target="_blank" method="get" name="url2go">

Although some browsers handles this case depends up to the settings. For example in IE9 you may need to change the setting of the browser.

or modify yoour function like this:-

 function gotoURL() {
 var newURL = ("http://tulyita.hu/pr2info.php?name=" + document.url2go.go.value)
 window.open(newURL,'_blank');
 }
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
0

Modify your function to

function gotoURL() {
    var newURL = "http://tulyita.hu/pr2info.php?name=" + document.url2go.go.value;
    window.open(newURL, "_blank");
}
Ry-
  • 218,210
  • 55
  • 464
  • 476