在不重新加载页面的情况下更改URL [英] Changing the URL without reloading the page

查看:81
本文介绍了在不重新加载页面的情况下更改URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以在不重新加载页面的情况下更改浏览器中的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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆