Js获取页面地址参数 复制代码 代码如下: function getUrlPara(paraName) { var sUrl = location.href; var sReg = "(?://?|&){1}" + paraName + "=([^&]*)" var re = new RegExp(sReg, "gi"); re.exec(sUrl); return RegExp.$1; }
地址跳转 复制代码 代码如下: var pn = $("#gotopagenum").val();//#gotopagenum是文本框的id属性 location.href = "NewList.aspx?pagenum="+pn;//location.href实现客户端页面的跳转
千分位 复制代码 代码如下: function Convert(money) { var s = money; //获取小数型数据 s += ""; if (s.indexOf(".") == -1) s += ".00"; //如果没有小数点,在后面补个小数点和00 if (/.d$/.test(s)) s += "0"; //正则判断 while (/d{4}(.|,)/.test(s)) //符合条件则进行替换 s = s.replace(/(d)(d{3}(.|,))/, "$1,$2"); //每隔3位添加一个 return s; }
判断是否数字 复制代码 代码如下: function IsNumeric(txt) { if (txt == "") { return false; }
if (txt.indexOf(",") > 0) { txt = txt.replace(",", ""); }
Js 获取时间戳,在某些情景下代替Guid 复制代码 代码如下: function NowTimeCode() { var Result="";
var now = new Date();
var year = now.getYear();
if (now.getYear() < 1900) { year = now.getYear() + 1900; }
var month = now.getMonth() + 1; var day = now.getDate(); var hour = now.getHours(); var minutes = now.getMinutes(); var second = now.getSeconds(); var millisecond = now.getMilliseconds();
if (month < 10) month = "0" + month; if (day < 10) day = "0"+ day; if (hour < 10) hour = "0"+ hour; if (minutes < 10) minutes = "0"+ minutes; if (second < 10) second = "0"+ second;