开发者

independent Cross Browser Library to handle location.hash

I need an independent Cross Browser Javascript Library to handle location.hash. not jQuery Specific. not dojo.hash. and if thats makes use of HTML 5 thats always 开发者_StackOverflowwelcome


In lieu of native hashchange support (IE8+, FFx 3.6+, WebKits from 528+), you'll need to poll the location hash for changes.


I don't know about any lib, but you can use a cross-browser function to handle the location.hash and then integrate it into your desired lib.
You could use the watch property implementation to act as an observer over the "document.location.hash" object. Then, the syntax would be something like :

window.location.watch(
  'hash',
  function(id,oldVal,newVal){
     console.log("the window's hash value has changed from "+oldval+" to "+newVal);
  }
);
if you want to do it this way, not to wait for an existing library to implement their own cross-browser method, I find the "watch" method as a very good start. You can see disscutions on this topic here.


This has all you need: The All-In-One Entirely-Not-Alphabetical No-Bullshit Guide to HTML5 Fallbacks You can see different libraries under the Browser State Management section.

For a good hash change library see this one: History.js

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜