【发布时间】:2016-06-01 15:15:50
【问题描述】:
如何检查页面url是否包含'#'字符加上一些随机数字
例如www.google.de/#1234
if( window.location.href.indexOf('#') > 0 ){
alert('true');
}
indexOf 是否支持正则表达式?
【问题讨论】:
-
为什么需要知道它的索引?只需使用
.match()函数来测试正则表达式是否匹配? -
你不能只测试
window.location.hash中的内容吗?
标签: javascript regex indexof