123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485 |
- /*
- * 打开新窗口 f:链接地址 n:窗口的名称 w:窗口的宽度 h:窗口的高度 s:窗口是否有滚动条,1:有滚动条;0:没有滚动条
- */
- function openWin(f, n, w, h, s)
- {
-
-
- var iTop = (window.screen.availHeight - 30 - w) / 2;
- var iLeft = (window.screen.availWidth - 10 - w) / 2;
-
- var iWidth = 500;
- var iHeight = 300;
- var iTop = (window.screen.availHeight - 30 - iHeight) / 2;
- var iLeft = (window.screen.availWidth - 10 - iWidth) / 2;
- //var win = window.open("request.aspx", "弹出窗口", "width=" + iWidth + ", height=" + iHeight + ",top=" + iTop + ",left=" + iLeft + ",toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no,alwaysRaised=yes,depended=yes");
- var result=window.open(f,n,"height="+h+",width="+w+",top=" + iTop +",left=" + iLeft + "," +s);
- //var result=window.showModalDialog(f,n,"dialogHeight:"+h+";dialogWidth:"+w+";"+s);
- if(result==true)
- {
- window.location.reload(true);
- }
- else
- {
- //window.location.reload(true);
- }
-
- }
- /*
- * 删除记录
- */
- function del(url, info)
- {
- if (confirm(info))
- {
- var result=window.showModalDialog(url,"window123","dialogHeight:234px;dialogWidth:271px;resizable:no;help:no;status:no;scroll:no");
- if(result==true)
- {
- window.location.reload(true);
- }
- else
- {
-
- }
- }
- else
- {
-
- }
- }
- /*
- * 校验checkbox
- */
- function checkAll(chkName, checkboxName, pageSize) {
- var src = event.srcElement;
- var chkN = eval("document.all." + chkName);
- if (src.checked) {
- chkN[0].checked = true;
- chkN[1].checked = true;
- for (var i = 0; i < pageSize; i++) {
- var chk = eval("document.all." + checkboxName + i);
- if (chk) {
- chk.checked = true;
- }
- }
- } else {
- chkN[0].checked = false;
- chkN[1].checked = false;
- for (var i = 0; i < pageSize; i++) {
- var chk = eval("document.all." + checkboxName + i);
- if (chk) {
- chk.checked = false;
- }
- }
- }
- }
- /*
- *
- */
- function makePages(maxPage, selectedPage, selectName) {
- var sel = eval("document.all." + selectName);
- sel.length = 0;
- for (var i = 1; i <= maxPage; i++) {
- sel.options[i] = new Option(i, i);
- if (sel.options[i] == selectedPage) {
- sel.options[i].selected = true;
- }
- }
- }
- /*
- * 替换字符串
- */
- function replaceStr(str) {
- var re = "/( )/gi";
- str = str.replace(re, "");
- re = "/\</gi";
- str = str.replace(re, "<");
- return str;
- }
- /*
- * 去掉左边空格
- */
- function LTrim(str) {
- var whitespace = new String(" \t\n\r");
- var s = new String(str);
- if (whitespace.indexOf(s.charAt(0)) != -1) {
- var j = 0, i = s.length;
- while (j < i && whitespace.indexOf(s.charAt(j)) != -1) {
- j++;
- }
- s = s.substring(j, i);
- }
- return s;
- }
- /*
- * 去掉右边空格
- */
- function RTrim(str) {
- var whitespace = new String(" \t\n\r");
- var s = new String(str);
- if (whitespace.indexOf(s.charAt(s.length - 1)) != -1) {
- var i = s.length - 1;
- while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) {
- i--;
- }
- s = s.substring(0, i + 1);
- }
- return s;
- }
- /*
- * 去掉两边空格
- */
- function Trim(str) {
- return RTrim(LTrim(str));
- }
- /*
- *
- */
- function exeOperation(exePath) {
- var obj = new ActiveXObject("Microsoft.XMLHTTP");
- obj.open("post", exePath, false);
- obj.send();
- var res = obj.responseText;
- var rs = Trim(res);
- if (rs.indexOf('true', 0) != -1) {
- return true;
- } else {
- return false;
- }
- }
- /*
- *
- */
- function exeValidate(exePath) {
- var obj = new ActiveXObject("Microsoft.XMLHTTP");
- obj.open("post", exePath, false);
- obj.send();
- var res = obj.responseText;
- var rs = Trim(res);
- if (rs.indexOf('validate_login_user', 0) != -1) {
- return true;
- } else {
- return false;
- }
- }
- /*
- * 显示
- */
- function validate_date(exePath) {
- var obj = new ActiveXObject("Microsoft.XMLHTTP");
- obj.open("post", exePath, false);
- obj.send();
- var res = obj.responseText;
- var rs = Trim(res);
- var begin_str = "<!--begin-->";
- var beginIndex = rs.indexOf(begin_str) + begin_str.length;
- var endIndex = rs.indexOf("<!--end-->");
- rs = ((beginIndex >= 0) && (endIndex >= 0)) ? rs.substring(beginIndex,
- endIndex) : "";
- return Trim(rs);
- }
- /*
- * 校验是否数字
- */
- function checkNumber(name, TempS) {
- for (Count = 0; Count < TempS.length; Count++) {
- TempChar = TempS.substring(Count, Count + 1);
- RefString = "0123456789";
- if (RefString.indexOf(TempChar, 0) == -1) {
- alert("请输入数字");
- eval("document.all." + name).focus();
- return false;
- }
- }
- }
- /*
- * 是否有非法字符
- */
- function chksafe(a) {
- fibdn = new Array("'", "\\");
- i = fibdn.length;
- j = a.length;
- for (ii = 0; ii < i; ii++) {
- for (jj = 0; jj < j; jj++) {
- temp1 = a.charAt(jj);
- temp2 = fibdn[ii];
- if (temp1 == temp2) {
- return false;
- }
- }
- }
- return true;
- }
- /*
- *
- */
- function fucCheckNUM(NUM) {
- var i, j, strTemp;
- strTemp = "0123456789";
- if (NUM.length == 0)
- return false;
- for (i = 0; i < NUM.length; i++) {
- j = strTemp.indexOf(NUM.charAt(i));
- if (j == -1) {
- return false;
- }
- }
- return true;
- }
- /*
- *
- */
- function fucCheckLength(strTemp) {
- var i, sum;
- sum = 0;
- for (i = 0; i < strTemp.length; i++) {
- if ((strTemp.charCodeAt(i) >= 0) && (strTemp.charCodeAt(i) <= 255)) {
- sum = sum + 1;
- } else {
- sum = sum + 2;
- }
- }
- return sum;
- }
- /*
- *
- */
- function chkElements(name, errMsg, max_length, lengthMsg) {
- var el_name = eval("document.all." + name);
- var v = el_name.value;
- if (!chksafe(v)) {
- el_name.focus();
- alert(errMsg);
- return false;
- } else if (fucCheckLength(v) > max_length) {
- el_name.focus();
- alert(lengthMsg);
- return false;
- }
- return true;
- }
- /*
- * 校验空字符串
- */
- function checkNullStr(name, msg) {
- var el_name = eval("document.all." + name);
- if (Trim(el_name.value).length == 0) {
- alert(msg);
- el_name.focus();
- return false;
- }
- return true;
- }
- /*
- * 显示日期控jian
- */
- function GetDate(nText, para) {
- var v_url = para == "1" ? "./common/data.html" : "../../common/data.html";
- var reVal = window
- .showModalDialog(
- v_url,
- 'data',
- "status:no;center:yes;scroll:no;resizable:no;dialogWidth:255px;dialogHeight:260px");
- if (reVal != null) {
- var n = eval("document.all." + nText);
- n.value = reVal;
- }
- }
- /*
- * 按比例缩小图片
- */
- function DrawImage(ImgD, iwidth, iheight) {
- var flag = false;
- var image = new Image();
- image.src = ImgD.src;
- if (image.width > 0 && image.height > 0) {
- flag = true;
- if (image.width / image.height >= iwidth / iheight) {
- if (image.width > iwidth) {
- ImgD.width = iwidth;
- ImgD.height = (image.height * iwidth) / image.width;
- } else {
- ImgD.width = image.width;
- ImgD.height = image.height;
- }
- // ImgD.alt=image.width+"×"+image.height;
- } else {
- if (image.height > iheight) {
- ImgD.height = iheight;
- ImgD.width = (image.width * iheight) / image.height;
- } else {
- ImgD.width = image.width;
- ImgD.height = image.height;
- }
- // ImgD.alt=image.width+"×"+image.height;
- }
- }
- ImgD.style.visibility = "visible";
- }
- /*
- * 回车键转为Tab键
- */
- function enterTab() {
- if (event.keyCode == 13) {
- oElement = document.activeElement;
- if (oElement.tagName != "TEXTAREA" && oElement.type != "button")
- event.keyCode = 9;
- return;
- }
- }
- /*
- *
- */
- function objectEval(text) {
- text = text.replace(/\n/g, " ");
- text = text.replace(/\r/g, " ");
- if (text.match(/^\s*\{.*\}\s*$/)) {
- text = "[" + text + "]";
- }
- return eval(text)[0];
- }
- /*
- * 打开领导查询页面 action - 查询的Action method - 调用的方法 title - 标题message name -
- * 员工选择域的name
- */
- function openLeaderQuery(action, method, title, name) {
- openWin("../../common/selectStaff.jsp?action=" + action + "&method="
- + method + "&title=" + title + "&name=" + name,
- "public_leader_find_page", "400", "150");
- }
- /*
- * 第一行变色
- */
- function chgColor() {
- var v_table = document.all["PowerTable"];
- var v_row = v_table.rows[1];
- var len = v_row.cells.length;
- for (var i = 0; i < len; i++) {
- var v_cell = v_row.cells[i];
- v_cell.style.backgroundColor = "yellow";
- }
- }
- /*
- * 第一行变色
- */
- function chgColor2() {
- var v_table = document.all["PowerTable"];
- var rows_count = v_table.rows.length;
- var v_row, v_cell, temp_len, len;
- var rowspan = 0;
- // get rowspan
- if (v_table.rows.length > 1) {
- len = v_table.rows[1].cells.length;
- for (var r = 2; r < rows_count; r++) {
- v_row = v_table.rows[r];
- temp_len = v_row.cells.length;
- if (temp_len == len) {
- rowspan = r - 1;
- break;
- }
- }
- rowspan = (rowspan > 0) ? (rowspan + 1) : rows_count;
- for (var r = 1; r < rowspan; r++) {
- v_row = v_table.rows[r];
- for (var t = 0; t < v_row.cells.length; t++) {
- v_cell = v_row.cells[t];
- v_cell.style.backgroundColor = "yellow";
- }
- }
- }
- }
- /*
- * 添加页面载入后触发的shijian
- */
- function addLoadEvent(func) {
- var oldonload = window.onload;
- if (typeof(window.onload) != "function") {
- window.onload = func;
- } else {
- window.onload = function() {
- oldonload();
- func();
- }
- }
- }
- // adsName:名称,adsUrl:地址,sTime:时间(小时) add by wujie 2005.12.12
- function PopAds(adsName, adsUrl, sTime, number, w, h, s) {
- if (document.cookie.indexOf(adsName) == -1) {
- window.open(adsUrl, adsName);
- self.focus();
- var expireDate = new Date();
- var lefttime = 1000 * (3600 * sTime);
- expireDate.setTime(expireDate.getTime() + lefttime);
- document.cookie = adsName + "=yes" + "; expires="
- + expireDate.toGMTString() + ";";
- }
- openWin(adsUrl, number, w, h, s);
- }
|