Eri*_*ric 99 javascript jquery split
我为什么要......
未捕获的TypeError:string.split不是函数
......当我跑...
var string = document.location;
var split = string.split('/');Run Code Online (Sandbox Code Playgroud)
小智 193
改变这个......
var string = document.location;
Run Code Online (Sandbox Code Playgroud)
对...
var string = document.location + '';
Run Code Online (Sandbox Code Playgroud)
这是因为document.location是一个Location对象.默认.toString()值以字符串形式返回位置,因此串联将触发该位置.
您还可以使用document.URL获取字符串.
che*_*263 61
也许
string = document.location.href;
arrayOfStrings = string.toString().split('/');
Run Code Online (Sandbox Code Playgroud)
假设您想要当前的网址
dst*_*arh 11
跑这个
// you'll see that it prints Object
console.log(typeof document.location);
Run Code Online (Sandbox Code Playgroud)
你想要document.location.toString()或document.location.href
| 归档时间: |
|
| 查看次数: |
248291 次 |
| 最近记录: |