0

I want to open the url in the same window, my code below works fine if i open the url in another tab, but when i added the _self target to open it in the same window, it doesn't working :/ where is my error?

<input type="text" name="url" id="url" value="brad.jpg" onclick="this.value=''" /><br/><br/>
<input type="submit"  onclick="javascript: window.open('http://MyURL.net/' + document.getElementById('url').value, '_self');">
Nemani
  • 778
  • 5
  • 12
bil80
  • 41
  • 7

2 Answers2

1

Extracted the code into a function and it works fine:

function callSubmit() {
  window.open('http://MyURL.net/' + document.getElementById('url').value, '_self');
}
<input type="text" name="url" id="url" value="brad.jpg" onclick="this.value=''" /><br/><br/>
<input type="submit" onclick="callSubmit()">
Milan Chheda
  • 8,159
  • 3
  • 20
  • 35
0

See this Fiddle : Fiddle

<input type="text" name="url" id="url" value="brad.jpg" 

onclick="this.value=''" /><br/><br/>
<input type="submit"  onclick="window.open('http://www.google.co.in');" target='_blank'>
Maulik
  • 765
  • 3
  • 14