Open URL in same window and in same tab

user1065055 picture user1065055 · Dec 10, 2011 · Viewed 964.1k times · Source

I want to open a link in the same window and in the same tab that contains the page with the link.

When I try to open a link by using window.open, then it opens in new tab—not in the same tab in the same window.

Answer

vdbuilder picture vdbuilder · Dec 10, 2011

You need to use the name attribute:

window.open("https://www.youraddress.com","_self")

Edit: Url should be prepended with protocol. Without it tries to open relative url. Tested in Chrome 59, Firefox 54 and IE 11.