简体   繁体   中英

I tried to open html in a new tab and tried //window.open(“home.html”, '_self'); but it did not work

I want to open new HTML page in the same tab. I tried using window.open('home.html','_self'); , but this does not work. However, if I use window.open('home.html'); , it opens in a new window.

How can I open HTML in the same page? I have tried all of these but none of them worked:

//window.open("home.html", '_top');
//window.location.replace("home.html");
//window.open('home.html','_self');
//window.location.assign("home.html")

Try using the window.location.href function.

Eg window.location.href = "home.html";

I'm not sure you want to use this in HTML or JQuery...whatever:

HTML

<a href="home.html">Home</a>

Jquery

location.href = "home.html";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM