判断访问端是否是移动设备,如果是移动设备就重定向到,移动端界面。
var uri = location.href; var domainWap = "http://m.vmall.com"; if(uri == domainMain || uri == (domainMain + "/index.html") || uri == (domainMain + "/")) { //判断客户端是否是移动设备,还可以判断是什么浏览器Chrome,Firefox,IE //如果是移动设备就重定向到移动界面 if(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) { window.location.href = domainWap; } }
//读取cookie中指定的key,并对value进行处理 cookieGet=function(a){ var f=null; if(document.cookie&&document.cookie!=""){ var d=document.cookie.split(";"); for(var c=0;c<d.length;c++){ //将cookie中的key中的空格去掉 var b=(d[c]||"").replace(/^(\s|\u00A0)+|(\s|\u00A0)+$/g,""); if(b.substring(0,a.length+1)==(a+"=")){ var e=function(i){ i=i.replace(/\+/g," "); var h=‘()<>@,;:\\"/[]?={}‘; //如果i中包含h中的字符,就去掉前后“ for(var g=0;g<h.length;g++){ if(i.indexOf(h.charAt(g))!=-1){ if(i.startWith(‘"‘)){i=i.substring(1)} if(i.endWith(‘"‘)){i=i.substring(0,i.length-1)} break; } } //解码uri,将字符串解码成url return decodeURIComponent(i) }; f=e(b.substring(a.length+1)); break; } } } return f };
var b = "http%3A%2F%2Fwww.vmall.com%2Faccount%2Fcaslogin%3Furl%3D"; var c = "http://cart.vmall.com/cart/cart.html?"; alert(decodeURIComponent(b));//解码:http://www.vmall.com/Faccount/caslogin?url= alert(encodeURIComponent(c));//编码:http%3A%2F%2Fcart.vmall.com%2Fcart%2Fcart.html%3F
时间: 2024-10-31 13:10:49