正则表达式
<script> var str = "(08:30-10:00)"; var patt = /^[(][0-9]{2}:[0-9]{2}-[0-9]{2}:[0-9]{2}[)]$/; var res = patt.test(str); document.write("<br/><br/>" + res); </script>
动态获取验证码
onclick="this.src='/Login/GetVerifyCodeImage/' + (new Date()).valueOf()"
js数值转换
ys1.push(parseFloat(obj.result[item]).toFixed(1));
获取可见屏幕的宽度
var windowWidth = document.body.clientWidth; //获取可见屏幕的宽度
var windowHeight = document.body.clientHeight; //获取可见屏幕的高度
是否是PC、获取url参数、更新url
function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod" ]; var flag = true; for (var v = 0; v < Agents.length; v++) { if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; } } return flag; } function getQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return decodeURIComponent(r[2]); return ''; } function updateURL() { if(location.href.indexOf('?')!=-1){ window.location.href = window.location.href+'&t='+new Date().getTime(); }else{ window.location.href = window.location.href+'?t='+new Date().getTime(); } }