最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I change URL without refreshing page like Google+? - Stack Overflow

programmeradmin4浏览0评论

When I was examining Google+, I'm surprized when I see usage of URLs. Google profile URLs change without refresing page. For example this is a photos tab URL: When you click Videos tab, URL exactly goes to without refreshing page. How Google coders success this?

When I was examining Google+, I'm surprized when I see usage of URLs. Google profile URLs change without refresing page. For example this is a photos tab URL: https://plus.google./104560124403688998123/photos When you click Videos tab, URL exactly goes to https://plus.google./104560124403688998123/videos without refreshing page. How Google coders success this?

Share Improve this question asked Jul 4, 2011 at 23:18 Murat ÇorluMurat Çorlu 8,5855 gold badges56 silver badges82 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 7

Have a look at the history object https://developer.mozilla/en/DOM/Manipulating_the_browser_history

Especially history.pushState and history.replaceState

(Should mention that this only works in modern browsers, for old ones use hashes).

This is about HTML 5. take a look at "onpopstate event". For further information go to the link. http://spoiledmilk.dk/blog/html5-changing-the-browser-url-without-refreshing-page

You could try using a pushState. You can change the URL to another URL within the same domain, but can not change the domain for security reasons.In Javascript, you can use.

window.history.pushState(“object or string”, “Title”, “/new-url”);

Object and string is your domain ex. www.google.co.in title you can give whats you want. and lastly you place new url ex. 'webhp?source=search_app'

ex. window.history.pushState(“www.google.co.in”, “Google”, “/webhp?source=search_app”);

You could try using a hash. This is not how google does it, but it doesn't force a refresh. In Javascript, you can use

parent.location.hash = "Text";

so that the URL will be http://yoursite./yourpage#text

Edit: This seems to be new to Google+. GMail uses a hash like

https://mail.google./mail/u/1/#inbox/130f48da33c5330
发布评论

评论列表(0)

  1. 暂无评论