How To Open URL in same window and in same tab ??? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 11

How To Open URL in same window and in same tab ???

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.

27th Apr 2017, 10:30 AM
Kailash Loncha
Kailash Loncha - avatar
7 Respostas
+ 23
If you want to do this in HTML: <a href = "page.html" target = "_self"> </a> Else, use Javascript: window.open('page.html', '_self'); Bye. :)
27th Apr 2017, 11:04 AM
Maz
Maz - avatar
+ 14
Thank You @Maz šŸ˜Š
27th Apr 2017, 2:49 PM
Kailash Loncha
Kailash Loncha - avatar
+ 13
Thank You @Oliver
27th Apr 2017, 4:15 PM
Kailash Loncha
Kailash Loncha - avatar
+ 13
Thank You @Amit
27th Apr 2017, 4:15 PM
Kailash Loncha
Kailash Loncha - avatar
+ 5
try to use location.href = "http://example.com";
27th Apr 2017, 11:08 AM
Oliver
+ 3
target=_blank is used to open link in new tab, what if we remove target attribute, won't that help in html, and In JavaScript by default would be different like opening in new tab ..... that's why it is not working.
27th Apr 2017, 12:05 PM
amit
amit - avatar
0
you can also use, window.location.replace, to tab in the same window
31st Aug 2017, 6:34 PM
Petro christopher
Petro christopher - avatar