admin管理员组文章数量:1332377
I really wonder why facebook and google can change the url without reloading the page? they just change the block or content in their site.
I notice that when I am using facebook, when click on the "new feed" the url is "/" and the page didn't reload, then i click on "messages" the url changed to "/" and the page still not reload just change the "content" block of the site.
So how do I change url without reloading the page?
edit: i got the answer.
there are 2 cases here:
- browser support html5 (Firefox 3.6 + etc.): using html5 history. (example: www.facebook => www.facebook/messages )
- browser dosn't support html5 (IE6, IE7, IE8 etc.): using hash tag (#) (example: www.facebook => www.facebook/#!/messages )
hope this help to who have doubt like me.
I really wonder why facebook and google can change the url without reloading the page? they just change the block or content in their site.
I notice that when I am using facebook, when click on the "new feed" the url is "http://www.facebook./" and the page didn't reload, then i click on "messages" the url changed to "http://www.facebook./messages/" and the page still not reload just change the "content" block of the site.
So how do I change url without reloading the page?
edit: i got the answer.
there are 2 cases here:
- browser support html5 (Firefox 3.6 + etc.): using html5 history. (example: www.facebook. => www.facebook./messages )
- browser dosn't support html5 (IE6, IE7, IE8 etc.): using hash tag (#) (example: www.facebook. => www.facebook./#!/messages )
hope this help to who have doubt like me.
Share Improve this question edited Sep 10, 2011 at 16:18 Alwayz Change asked Sep 10, 2011 at 15:05 Alwayz ChangeAlwayz Change 2251 gold badge4 silver badges13 bronze badges 04 Answers
Reset to default 8Have you looked into the history API for Javascript?
http://diveintohtml5.ep.io/history.html
EDIT: You could also use mod_rewrite with apache and then, but that would cause a refresh.
Or there is this JQuery Plugin
http://www.asual./jquery/address/
The URL usually changes to http://facebook/#!messages, so the change of the "fragment" URL part doesn't make the browser reload the page. Instead, there is some JavaScript library that watches fragment changes and make appropriate requests in order to reload the page content.
The usage of #!
is almost being a "standard" for doing these things, I've seen this used elsewhere (eg. on Twitter). I don't remember if they all use the same library or just the naming convention, but you should be able to dig about it on the fb/twitter developers pages.
You could look into the Content-Location HTTP header for this purpose. See here for more info.
I code on JSBin., mainly use CSS and HTML (Abandoned Javascript loooong time ago) and have a question. For example a page's URL is http://www.codingrules./ Well, using HTML, How can I change that URL to for example http://www.ilovecoding.
本文标签: phphow to change url in browser url boxStack Overflow
版权声明:本文标题:php - how to change url in browser url box? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742295510a2448642.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论