function addCookie(objName,objValue,objHours){//添加cookie var str = objName + "=" + escape(objValue); if(objHours > 0){//为0时不设定过期时间,浏览器关闭时cookie自动消失 var date = new Date(); var ms = objHours*3600*1000; date.setTime(date.getTime() + ms); str +=
一.Js中获取地址栏参数 //从地址栏获取想要的参数 function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } va
<script> String.prototype.format = function (kwargs) { var ret = this.replace(/\{(\w+)\}/g, function (substring, args) { return kwargs[args] }); } </script> js 中是没有 format 这种格式化的方法的. 但是 因为字符串也是一个原型类,所有的方法都在 prototype中. 所以可以向这个里面添加一个 自定义的 form