获取上一级的链接地址:document.referrer
var beforeHref="" ;
获取str字符串aaaaa到?中间的信息
var substr = str.match(/aaaaa\/(\S*)\?/);
获取上一级链接地址中最后一个/后面的action
beforeHref.slice(beforeHref.lastIndexOf("/"),(beforeHref.indexOf("?")=="-1"?beforeHref.length:beforeHref.indexOf("?")))
document.referrer.slice(document.referrer.lastIndexOf("/")+1,(document.referrer.indexOf("?")=="-1"?document.referrer.length:document.referrer.indexOf("?")))
正则方式获取:
获取以?号结尾以/开头的字符串
reg=/ \w(?=\?)/g
获取最后的字符串
var substr = subhref.match(/\w+(?!.)/g);
var subhref="http://user.qzone.qq.com/605294485/SSif1234ocented?asdfagg=3456&rewt=ewr"
var substr=((subhref.match(/(?=\?)/g)!=null)?subhref.match(/\w+(?=\?)/g):subhref.match(/\w+(?!.)/g))
console.log(substr);
1、设置或获取整个 URL 为字符串:
window.location.href
2、设置或获取与 URL 关联的端口号码:
window.location.port
3、设置或获取 URL 的协议部分
window.location.protocol
4、设置或获取 href 属性中跟在问号后面的部分
window.location.search
获取str字符串aaaaa到?中间的信息
var substr = str.match(/aaaaa\/(\S*)\?/);