在不重新加载页面的情况下更改URL [英] Changing the URL without reloading the page
问题描述
我想知道是否可以在不重新加载页面的情况下更改浏览器中的URL内容?
我使用jQuery和Ajax加载新的部件我的页面。当我选择产品一时,直接链接将是 mysite.com/product1
,而产品二将是 mysite.com/product2
,但我不想将网站重新加载到这些页面。 您将拥有如果您想阻止页面重新加载,请添加散列#
。
css-tricks.com的优秀截屏,看看:
I would like to know if it's possible to change the contents of the URL in the browser without reloading the page?
I use jQuery and Ajax to load new parts of my page. When I choose "product one", the direct link would be mysite.com/product1
and for "product two" would be mysite.com/product2
, but I don't want to reload the site to these pages.
You will have to add hash #
if you want to prevent page from reloading.
The css-tricks.com has an excellent screencast on that, have a look at:
Best Practices with Dynamic Content
这篇关于在不重新加载页面的情况下更改URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!