我需要通过 Javascript 解析给定的 url,但我无法使用 .split() 来完成此操作。
IE:
var str = window.location.pathname;
var substr = str.split('/');
alert(substr)
如果我输入此网址“http://mydomain.com/myaddress/page/2/”,我有 thoose 值“myaddress,page,2”
但如果我插入 # 而不是 / 则不起作用
Use window.location.hash,它会为您提供分解的部分。
另外,你正试图“分裂”#
找不到的字符window.location.pathname
, only window.location.hash
--除非你使用window.location
并搜索整个网址。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)