关于截取URL地址参数的方法


JS获取URL中最后一个斜杠前面的内容

var url = window.location.href; var index = url.lastIndexOf("\/"); str = url.substring(0,index+1); console.log(str); 

JS获取URL中最后一个斜杠后面的内容

var url = window.location.href; var index = url.lastIndexOf("\/"); str = url.substring(index + 1,url.length); console.log(str);

原地址链接:https://www.jianshu.com/p/017366f5585e


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM