几个常用的JS
程序员文章站
2022-03-11 08:44:22
...
// JavaScript Document
//+---------------------------------------------------
//| 打开模式窗口,返回新窗口的操作值
//+---------------------------------------------------
function PopModalWindow(url,width,height)
{
var result=window.showModalDialog(url,window,"dialogWidth:"+width+"px;dialogHeight:"+height+"px;center:yes;status:no;scroll:no;dialogHide:no;resizable:no;help:no;edge:sunken;");
return result;
}
function PopModalWindowScroll(url,width,height)
{
var result=window.showModalDialog(url,window,"dialogWidth:"+width+"px;dialogHeight:"+height+"px;center:yes;status:no;scroll:yes;dialogHide:no;resizable:no;help:no;edge:sunken;");
return result;
}
//+---------------------------------------------------
//| 打开新窗口,返回新窗口的操作值
//+---------------------------------------------------
function PopNewWindow(sUrl,iWidth,iHeight)
{
l = (screen.width - iWidth)/2-10;
t = (screen.height- iHeight)/2-16;
window.open(sUrl,"","resizable=1,width="+iWidth+",height="+iHeight+",left="+l+",top="+t);
}
function PopNewWindowScroll(sUrl,iWidth,iHeight)
{
l = (screen.width - iWidth)/2-10;
t = (screen.height- iHeight)/2-16;
window.open(sUrl,"","scrollbars=1,resizable=1,width="+iWidth+",height="+iHeight+",left="+l+",top="+t);
}
//+---------------------------------------------------
//| 控制只輸入數字
//+---------------------------------------------------
function limitNum(obj) {
if(obj.value.replace(/[0-9\.]+/g,"").length>0) {
alert('请输入数字')
obj.value=0;
}
}
//+---------------------------------------------------
//| 控制表单全选或取消
//+---------------------------------------------------
function checkall(form, prefix, checkall) {
var checkall = checkall ? checkall : 'chkall';
for(var i = 0; i < form.elements.length; i++) {
var e = form.elements[i];
if(e.name != checkall && (!prefix || (prefix && e.name.match(prefix)))) {
e.checked = form.elements[checkall].checked;
}
}
}
function ClearData(obj,clearVal)
{
if (obj.value == "")
{
obj.value = clearVal;
}
else if (obj.value == clearVal)
{
obj.value = "";
}
}
//+---------------------------------------------------
//| 合并合格列,引用Jquery.js使用
//+---------------------------------------------------
function table_rowspan(_w_table_id,_w_table_colnum){
_w_table_firsttd = "";
_w_table_currenttd = "";
_w_table_SpanNum = 0;
_w_table_Obj = $j(_w_table_id + " tr td:nth-child(" + _w_table_colnum + ")");
_w_table_Obj.each(function(i){
if(i==0){
_w_table_firsttd = $j(this);
_w_table_SpanNum = 1;
}else{
_w_table_currenttd = $j(this);
if(_w_table_firsttd.text()==_w_table_currenttd.text()){
_w_table_SpanNum++;
_w_table_currenttd.hide(); //remove();
_w_table_firsttd.attr("rowSpan",_w_table_SpanNum);
}else{
_w_table_firsttd = $j(this);
_w_table_SpanNum = 1;
}
}
});
}