【发布时间】:2013-01-19 17:14:41
【问题描述】:
以下代码在 Chrome 中给我一个错误。 window.location.href 似乎没有返回字符串,但这似乎很疯狂。
代码如下:
var theUrl = "" + window.location.href;
var hashValue = theUrl.contains("#") ? theUrl.split('#')[1] : null; (This is line 6)
这会在 Chrome 中返回以下错误:
Uncaught TypeError: Object someUrl#someHash has no method 'contains' myFile.js:6
(anonymous function) faq.js:6
k jquery.min.js:2
l.fireWith jquery.min.js:2
p.extend.ready jquery.min.js:2
D
有什么想法吗?
编辑:也尝试使用document.URL 无济于事。
【问题讨论】:
-
typeof(window.location.href)返回什么? -
你能做一个可重复的 jsfiddle.net 测试用例吗?
-
@MikkoOhtamaa 现在尝试。
-
@lostsource 返回
string全部小写。
标签: javascript google-chrome dom