简体   繁体   中英

Javascript Code to go back to main page not previously browsed Page

如何返回主页而不是先前浏览过的页面。我使用了javascript链接,但它返回的是先前浏览过的页面。任何人都可以告诉我如何返回任何已定义类别的主页,例如,如果我正在浏览任何我们拥有主分类然后子分类的产品,因此如何使用javascript编码的超链接从子分类导航到主分类。

You can use window's property object location and its attribute origin :

window.location.href = window.location.origin

Using this code on this page will relocate you to https://stackoverflow.com/ , and this will also keep a port number if you have any specific defined, like http://localhost:8888/ in your development environment.

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