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 :
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.
window.location.watch(
'hash',
function(id,oldVal,newVal){
console.log("the window's hash value has changed from "+oldval+" to "+newVal);
}
);
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
精彩评论