【发布时间】:2012-10-30 16:07:12
【问题描述】:
我在 MVC3 视图中有以下代码:
$(document).ready(function () {
if (window.location.hash) {
var manager= new Manager();
manager.doSomeStuff(window.location.hash);
}
});
有趣的是,当URL中没有hash标签,或者只有hash标签的例子:
http://localhost:1223/Index/AboutUs
http://localhost:1223/Index/AboutUs#
window.location.hash 为空且函数未执行时。
但是当哈希标签中有一些值时:
http://localhost:1223/Index/AboutUs#categoryId=5&manufacturerId=8
window.location.hash 中的值为#categoryId=5&manufacturerId=8
你能解释一下为什么#标签包含在值中,为什么当#标签后面没有值时,window.location.hash是空的。
【问题讨论】:
标签: javascript jquery asp.net-mvc-3 url hashtag