一、防止ie浏览器按backspace回退页面
//防止后退返回页面,如果非文本框、密码框、文本域控件,或控件非可用装填,则禁用后退按键 var ua=navigator.userAgent.toLowerCase(); var isIE=ua.indexOf("msie")>-1; window.document.onkeydown =function(e){ var e = e; var obj; //事件源 var t; //控件类型 var keyCode; //按键ascii码 if(isIE){ e = event || window.event; keyCode = e.keyCode; }else{ keyCode = e.keyCode || e.which; if(keyCode==undefined||keyCode==null||keyCode==‘‘){ keyCode=String.fromCharCode(e.charCode); } } obj = e.target || e.srcElement; //获取事件源 t = obj.type || obj.getAttribute(‘type‘); if (e.keyCode==8 && (obj.readOnly || obj.disabled || (t != "password" && t != "text" && t != "textarea" && obj.tagName!==‘INPUT‘))) { return false; } };
二、获取页面传参
// 获取参数 function getUrlParam(name) { var urlArr = [],urlObj={}; name = decodeURI(name); urlArr=name.substring(1).split(‘&‘); for(var i =0;i<urlArr.length;i++){ var valueArr=urlArr[i].split(‘=‘); urlObj[valueArr[0]]=valueArr[1]; } return urlObj; }
时间: 2024-11-04 21:26:20