简体   繁体   English

如何在不重新加载的情况下更改浏览器栏网址

[英]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.

相关问题 如何在不重新加载页面的情况下更改浏览器 URL? - How to change the browser URL without reload the page? Facebook如何更改浏览器地址栏中的URL而不需要重新加载页面或使用#或? - How does Facebook change the URL in the browser's address bar without page reload or use of # or? 如何在不重新加载页面的情况下将浏览器地址栏中的 URL 更改为 angularJS - How to change URL in browser address bar with angularJS without reloading the page 更改浏览器URL和页面内容而无需重新加载和使用片段 - Change browser URL and page content without reload and without using fragments 如何更新地址栏中的URL,但不重新加载该URL? - How to update the URL in the address bar but without reload to that URL? 如何强制浏览器在不更改URL的情况下重新加载缓存的URL - How to force the browser to reload a cached URL without changing the URL 如何在不重新加载页面的情况下更改部分 url 浏览器? - How to change part of url browser witouth reload the page? 更新浏览器地址栏而不重新加载 - Update browser address bar without reload 更改 URL 无需重新加载页面 - Change URL without reload page 如何在不重新加载浏览器的情况下更改我的网址? - How to change my Url without reloading the browser?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM