常用js脚本

2019-06-03 14:56:30丽君

window.moveTo((screen.width-document.body.clientWidth-10)/2,(screen.height-document.body.clientHeight-30)/2);
}

// =========================================================================================================
// 检测下拉框必须选择其中一条
// ==========================================================================================================
function selNotEmpty(obj,sLabel){
var strTemp = "" ;
strTemp = JTrim(obj.value) ;
if (strTemp ==""){
strTemp = "“" + sLabel + "”不能为空,请选择正确的“" + sLabel + "”。";
window.alert(strTemp);
obj(0).selected=true ;
return true;
}
return false;
}

// =========================================================================================================
// 焦点定在传入的窗口中
// ==========================================================================================================
function fucusWin(winName){
try{
if(winName!=null){
winName.focus();
var sWinName=(winName.name).toString;
}
}
catch(e){
//alert(e); //忽略错误
}
}

// =========================================================================================================
// 关闭窗口
// ==========================================================================================================
function closeWin(winName){
try{
if(winName!=null){
winName.close();
}
}
catch(e){
}
}

// =========================================================================================================
// 限制输入回车键
// ==========================================================================================================
function JNotInputEnter(){
if(window.event.keyCode=13) window.event.keyCode=0;
}

// ================================================================
// 本函数用于限制文本输入框中只能输入整型数据[0-9]
// ================================================================ 
function JIntNumText(){
if ( !(((window.event.keyCode >= 48) && (window.event.keyCode <= 57)) 
|| (window.event.keyCode == 13)))
{
window.event.keyCode = 0 ;
}
}

// ================================================================
// 本函数用于限制文本输入框中只能输入字母[A-Za-z]
// ================================================================ 
function JInputLetter(){
if ( !(((window.event.keyCode >= 65) && (window.event.keyCode <= 90)) 
|| ((window.event.keyCode >= 97) && (window.event.keyCode <= 122))