[英]How to change browser bar url without reload
I have a website that generates the following URL on the home page in the browser bar: 我有一个网站,该网站在浏览器栏中的主页上生成以下URL:
http://example.com/int/bdf/eng/
I want change it to the following without reloading the page: 我想将其更改为以下内容而不重新加载页面:
http://example.com
Is there an IE8+ solution available? 是否有IE8 +解决方案?
i know about window.history.pushState("", "", "");
我知道window.history.pushState("", "", "");
but how to use it? 但是如何使用呢? Or would it be better to use a htaccess file? 还是使用htaccess文件会更好?
According to the W3C standards you can use the location hash property. 根据W3C标准,您可以使用位置哈希属性。
For an example URL like this: 对于这样的示例URL:
http://www.example.com/test.htm#part2
The location.hash value would be: "#part2" and here is a JSFiddle that shows you how you can use that. location.hash值为:“#part2”, 这是一个JSFiddle ,向您展示如何使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.