这是你在找什么:
http://haineault.com/blog/37/
(function(){
anchor = document.location.hash, handlers = [];
jQuery.extend({
anchorHandler: {
add: function(regexp, callback) {
if (typeof(regexp) == 'object') {
jQuery.map(regexp, function(arg){
args = {r: arg[0], cb: arg[1]};});}
else args = {r: regexp, cb: callback};
handlers.push(args);
return jQuery.anchorHandler;
}
}
})(document).ready(function(){
jQuery.map(handlers, function(handler){
match = anchor.match(handler.r) && anchor.match(handler.r)[0] || false;
if (match) handler.cb.apply(this, [match, (anchor || false)]);});});
})();
添加触发这样的:
$.anchorHandler
.add(/\#ch\-cheatsheet/, h.comment.showCheatsheet)
.add(/\#comment\-compose/, h.comment.showCompose)
.add(/\#comment\-\d+/, h.comment.focus);
在JS中:'document.location.hash' – jball 2010-10-20 18:38:17