/* 常用方法 */ /*跳转另一个窗口*/ function GoNewurl(url,data){ var str = ""; if (data != null){ for (var key in data){ if (str != "") str += "&"; str += key + "=" + data[key]; } str = GetCombinationUrl(url) + str; } location.href = url + str; } /*判断路径*/ function CheckUrl(url){ if (url!=null){ var reg = /^([a-zA-Z0-9\/]+)\.(\w+)\?([\d\w\s|\D\W\S]*)(&|[^&]|)$/; /*判断是否有问号*/ return url.match(reg); } return null; } /*获取组合路径*/ function GetCombinationUrl(url){ var str = ""; var m = CheckUrl(url); if (m != null){ if (m[4] != "&"){ str = "&"; } } else{ str = "?"; } return str; } /*刷新页面*/ function Reload(){ location.reload(); } /*重置信息*/ function ReForm(){ document.Form1.reset(); } /*返回*/ function Backpage(){ window.history.go(-1); } /*锚点定位*/ function scroller(x,y){ window.scrollTo(x,y); } /*预览文本域*/ function PView(s) { pr=window.open("",""," scrollbars=yes width=900 height=550 left=20 top=20"); pr.document.write(s); } /*屏蔽右键*/ function click(e) { if (document.all) { if (event.button==2||event.button==3) { oncontextmenu='return false'; } } if (document.layers) { if (e.which == 3) { oncontextmenu='return false'; } } } /*去掉前后空格*/ String.prototype.trim = function (){ return this.replace(/^( |[\s ])+|( |[\s ])+$/g,""); } /*字符串长度计算*/ function countCharacters(str) { var totalCount = 0; for (var i=0; i= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) { totalCount++; } else { totalCount+=2; } } return totalCount; } Date.prototype.Format = function(formatStr) { var str = formatStr; var Week = ['日','一','二','三','四','五','六']; str=str.replace(/yyyy|YYYY/,this.getFullYear()); str=str.replace(/yy|YY/,(this.getYear() % 100)>9?(this.getYear() % 100).toString():'0' + (this.getYear() % 100)); str=str.replace(/MM/,this.getMonth()+1>9?(this.getMonth()+1).toString():'0' + (this.getMonth()+1)); str=str.replace(/M/g,this.getMonth()+1); str=str.replace(/w|W/g,Week[this.getDay()]); str=str.replace(/dd|DD/,this.getDate()>9?this.getDate().toString():'0' + this.getDate()); str=str.replace(/d|D/g,this.getDate()); str=str.replace(/hh|HH/,this.getHours()>9?this.getHours().toString():'0' + this.getHours()); str=str.replace(/h|H/g,this.getHours()); str=str.replace(/mm/,this.getMinutes()>9?this.getMinutes().toString():'0' + this.getMinutes()); str=str.replace(/m/g,this.getMinutes()); str=str.replace(/ss|SS/,this.getSeconds()>9?this.getSeconds().toString():'0' + this.getSeconds()); str=str.replace(/s|S/g,this.getSeconds()); return str; } /*随机0-9随机数*/ function RndNum(n){ var rnd=""; for(var i=0;i<n;i++) rnd+=Math.floor(Math.random()*10); return rnd; }