开发者

window.location force to update?

I'm wondering is there a way for force window.location to update? I'm on a pa开发者_高级运维ge which uses ajax to generate results. However, the URL stays the same in the bar and so I can't grab the real URL. I'm wondering.. how would I grab the URL? can I force window.location to update without refreshing the page?

An example of the sort of page I'm talking about is google instant!


Are you looking to update the content and URL with AJAX? Just use History API provided by HTML5 browsers.


No you can't. If you don't control the page and they are not updating the URL in a way, then there is nothing you can do.

But if you have control, then it is your responsibility to either use the fragment identifier or HTML5's new history API to update the adress. But even if you use the history API, window.location won't get changed.

Update:

Not 100% sure what Google Instant page you are talking about, but if it is the "normal" Google page, then you will see that the URL updates after 1 or 2 seconds after you typed the query.

So you could add an event listener for the hashchange event and then grab the URL from window.location.


This question will be of interest:

How does facebook rewrite the source URL of a page in the browser address bar?


changing location.hash with jquery ui tabs

Add this to your current trigger. (I'm aware this is jQuery but the logic is the same)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜