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');">

4

2 Answers 2

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()">

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.