开发者

How does the back button work on beautyoftheweb.com?

开发者 https://www.devze.com 2023-01-17 00:10 出处:网络
I\'ve been looking for some javascript hooks for the back button in the browser. But they only seem to support back/forward between hashed url\'s. That is, you can only navigate from www.mysite.com#pa

I've been looking for some javascript hooks for the back button in the browser. But they only seem to support back/forward between hashed url's. That is, you can only navigate from www.mysite.com#page1 and www.mysite.com#page2, if you click back, and the url bec开发者_开发问答omes something without a hash, they all fail. Like this one: http://www.asual.com/jquery/address/samples/tabs/ Click one tab, then back, it won't work.

But on http://www.beautyoftheweb.com they've managed to get the backbutton to work between hashed and non-hashed url's. Any idea how they've done this?


Are you sure? I'm seeing a hash:

http://www.beautyoftheweb.com/#/highlights/all-around-fast
                              ^-- here

But assuming there are some URLs that don't have them: What kind of failures are you seeing elsewhere? I have an intranet app where I'm using Really Simple History for history management, and you can happily go backward and forward between URLs whether or not they're application URLs using the hash, application URLs not using the hash, or completely unrelated URLs for other pages/apps. (You can also bookmark the hashed ones, and the app comes back to the right place when you use it.) That works in my app because on initial load, I look to see what hash (if any) is present and reload that state as necessary. (I don't rely on — or even use — RSH's data-storage aspect, just the hash manipulations.)


Edit Just tried the live demo of the first jQuery history plug-in I found in a quick search. It handled going back and forth between "hashed" and "unhashed" URLs just fine. I went to the "#2" link, then edited the URL in the address bar to remove the hash entirely and pressed Enter. That took me to the correct page. Then clicking Back I got the "#2" page correctly. In fact, if you go here I'm linking directly to the "#2" link, and it loads its state accordingly. I think you've been seeing some naive use of history libraries where the coder hasn't handled the initial load correctly.


From what I see, all the URLs are of the form http://www.beautyoftheweb.com/#/<something>, for example: http://www.beautyoftheweb.com/#/experience/cnn - hence, all are using hashes.

0

精彩评论

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