use*_*666 1 javascript regex
我正在开发一个应用程序,并希望能够只从URL获取资源,所以我写了一个正则表达式,但它似乎没有工作,我得到一个未被捕获的类型错误.有人能帮忙吗?
var link = document.location; var res = link.match(/\/.*php/g);
Aln*_*tak 5
document.location不是字符串,而是Location具有描述URL的各个组件的属性的对象.因此它没有match方法.
document.location
Location
match
请尝试使用document.location.pathname.
document.location.pathname
归档时间:
11 年,3 月 前
查看次数:
53 次
最近记录: