window.open() should open the link in same tab

user2897174 picture user2897174 · Jan 27, 2015 · Viewed 30.2k times · Source

I am very new to javascript, and written a program that will open a querystring as link.
I used window.open() , but the link is opening in new tab,
I want to open this link in the same tab.
The code is below.

var strquerystring;  
if(fromvalue==""||tovalue==""){  
  alert('kindly fill all the details');
}else{
  window.open(strquerystring);
}

Answer

ozil picture ozil · Jan 27, 2015

You need to use the name attribute:

window.open("www.youraddress.com","_self");