//获取URL中的request参数 function getUrlParam(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) { return decodeURIComponent(r[2]); } else { return ""; } } //获取URL中的request参数 function getUrlParamByName(name) { var reg = new RegExp("-(.*?)\.html"); var r = window.location.href.match(reg); var str = ""; if (r != null) { str = decodeURIComponent(r[0]); } str = str.substring(1, str.lastIndexOf(".html")).trim(); if (str == null || str.length <= 0) { str = getUrlParam(name); } return str; } //弹出窗口,无滚动条 function openNoBarWin(url, widths, heights) { var features = "height=" + heights + ", width=" + widths + ", toolbar =yes, menubar=no, scrollbars=no, resizable=yes, location=no, status=no,top=200,left=200"; var w = window.open(url, "newwindow", features); w.focus(); } //弹出窗口,有滚动条 function openNoScroBarWin(url, widths, heights) { var features = "height=" + heights + ", width=" + widths + ", toolbar =yes, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no,top=200,left=200"; var w = window.open(url, "newwindow", features); w.focus(); } //弹出普通IE窗口 function openNormalWin(url, widths, heights) { var features = "height=" + heights + ", width=" + widths + ", toolbar =yes, menubar=yes, scrollbars=yes, resizable=yes, location=yes, status=yes"; var w = window.open(url, "newwindow", features); w.focus(); } function ViewProfile(urid) { openNormalWin("/Web/Profile/index.aspx?userid=" + urid + "&RndCode=" + UrlRndCode, "900", "480"); } //鼠标经过弹出层 function ShowTitleContent(TitleContent) { var event = new Event(event); $("mouseshow").style.display = "block"; $("mouseshow").innerHTML = '<img style="position:absolute; left:-7px; top:5px;" src="/Images/Hqen/tipArrow_blue.gif" alt="" />' + TitleContent; var eImg = $(event.target); $("mouseshow").style.left = ((eImg.getLeft()) + 20) + "px"; $("mouseshow").style.top = ((eImg.getTop()) + 2) + "px"; } function HiddenTitleContent() { $("mouseshow").style.display = "none"; } function getContentHtml() { var str = document.getElementById('Editor').contentWindow.document.getElementById('HtmlEditor').contentWindow.document.getElementsByTagName("BODY")[0].innerHTML; //alert(str); return str; } //把数据库里的"\n"替换成<br> function Db2HTML(str) { if (str == null || str == "") return ""; var strtmp = str; // strtmp = strtmp.replace("\n","<br>"); strtmp = (strtmp.replace(new RegExp("\n", "gm"), "<br>")); strtmp = (strtmp.replace(new RegExp(" ", "gm"), " ")); return strtmp; } //把<br>的替换成\n function HTML2Db(str) { if (str == null || str == "") return ""; var strtmp = str; strtmp = (strtmp.replace(new RegExp("<br>", "gm"), "\n")); strtmp = (strtmp.replace(new RegExp(" ", "gm"), " ")); return strtmp; } //去掉前后的空格 function Trim(str) { return str.replace(/(^\s*)|(\s*$)/g, ""); } //去掉左边的空格 function Ltrim(str) { return str.replace(/(^\s*)/g, ""); } //去掉右边的空格 function Rtrim(str) { return str.replace(/(\s*$)/g, ""); } //将空字符替换成Null function CheckNull(text) { if (text == null) { return null; } else if (text != null) { text = text.replace(/(^\s*)|(\s*$)/g, ""); if (text == "") { return null; } else { return text; } } } //验证是否为整数 function IsNumber(str) { var exp = /[^0-9()-]/g; if (str.search(exp) != -1) { return false; } return true; } //验证是否为正整数 function IsPlusNumber(str) { var exp = /[^0-9()]/g; if (str.search(exp) != -1) { return false; } return true; } //乘法函数,用来得到精确的乘法结果 //说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。 //调用:accMul(arg1,arg2) //返回值:arg1乘以arg2的精确结果 function ConvertMul(arg1, arg2) { var m = 0, s1 = arg1.toString(), s2 = arg2.toString(); try { m += s1.split(".")[1].length; } catch (e) { } try { m += s2.split(".")[1].length; } catch (e) { } return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m); } //加法函数,用来得到精确的加法结果 //说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。 //调用:accAdd(arg1,arg2) //返回值:arg1加上arg2的精确结果 function ConvertAdd(arg1, arg2) { var r1, r2, m; try { r1 = arg1.toString().split(".")[1].length; } catch (e) { r1 = 0; } try { r2 = arg2.toString().split(".")[1].length; } catch (e) { r2 = 0; } m = Math.pow(10, Math.max(r1, r2)); return (arg1 * m + arg2 * m) / m; } //减法函数,用来得到精确的减法结果 //说明:javascript的减法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。 //调用:ConvertSub(arg1,arg2) //返回值:arg1减去arg2的精确结果 function ConvertSub(arg1, arg2) { var r1, r2, m; try { r1 = arg1.toString().split(".")[1].length; } catch (e) { r1 = 0; } try { r2 = arg2.toString().split(".")[1].length; } catch (e) { r2 = 0; } m = Math.pow(10, Math.max(r1, r2)); return (arg1 * m - arg2 * m) / m; } //验证是否为金额格式,只精确两位小数。 function CheckIsMoney(str) { if (str == "" || str == null) { return true; } if (/^[+]?\d*\.{0,1}\d{0,2}$/.test(str)) { return true; } else { return false; } } //验证是否为金额格式,只精确一位小数。 function CheckIsDecimalMoney(str) { if (str == "" || str == null) { return true; } if (/^[+]?\d*\.{0,1}\d{0,1}$/.test(str)) { if (str.substr(str.length - 1, 1) == '.') { return false; } return true; } else { return false; } } //获取字符串的大小,返回字节的大小 function GetStringLength(text) { var codingText = text.replace(/[^\x00-\xff]/g, "**"); return codingText.length; }