⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 function.js

📁 功能简介: 前台: 1.用户名注册:登 录 名:密码:确认密码:性别:查询权限: 地址: 联系电话: 移动电话: E - mail: 工作单位 2.系统优点管理,公告新闻管理,联系我们管理
💻 JS
字号:
/* 
判断指定的内容是否为空,若为空则弹出 警告框 
*/ 
function isEmpty(theValue, strMsg){ 
if(theValue==""){ 
alert(strMsg+"不能为空!"); 
return true; 
} 
return false; 
} 
/* 
中文判断函数,允许生僻字用英文“*”代替 
返回true表示是符合条件,返回false表示不符合 
*/ 
function isChinese(str){ 
var badChar ="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
badChar += "abcdefghijklmnopqrstuvwxyz"; 
badChar += "0123456789"; 
badChar += " "+" ";//半角与全角空格 
badChar += "`~!@#$%^&()-_=+]\\\\|:;\\\\\'<,>?/";//不包含*或.的英文符号 
if(""==str){ 
return false; 
} 
for(var i=0;i<str.length;i++){ 
var c = str.charAt(i);//字符串str中的字符 
if(badChar.indexOf(c)<0){ 
return false; 
} 
} 
return true; 
} 
/* 
数字判断函数,返回true表示是全部数字,返回false表示不全部是数字 
*/ 
/*function isNumber(str){ 
if(""==str){ 
return false; 
} 
var reg = /\\D/; 
return str.match(reg)==null; 
} */

function isNumber(str)
{
	if(str=="")
	{return false;}
	if(str*1+""=="NaN")
	{return false;}
	return true;
}
/* 
判断给定的字符串是否为指定长度的数字 
是返回true,不是返回false 
*/ 
function isNumber_Ex(str,len){ 
if(""==str){ 
return false; 
} 

if(str.length!=len){ 
return false; 
} 

if(!isNumber(str)){ 
return false; 
} 
return true; 
} 

function checkEmail(EmailAddress){
//--------------------------------------------------------------------------------
//  Name				Mode		Description
//	EmailAddress		Input		the email address
//
//  Return Value        :   true/false
//	Return Type         :   boolean
//--------------------------------------------------------------------------------	
	var i=0;
	var chr;
	var len;
	var Numbers="0123456789";
	var UpperLetters="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var LowerLetters="abcdefghijklmnopqrstuvwxyz";
	var EmailChar= Numbers + UpperLetters + LowerLetters + "@-_.";
	
	len=EmailAddress.length;
	
	//validate all characters
	for(i=0;i<len;i++){
		chr=EmailAddress.charAt(i);
		if(EmailChar.indexOf(chr)==-1){			
			return false;
		}
	}
	
	//Email address must include "@"
	if(EmailAddress.indexOf("@")==-1) return false;		
	//Email address must include "."
	if(EmailAddress.indexOf(".")==-1) return false;	
	//Email address must include only one "@"
	if(EmailAddress.lastIndexOf("@")!=EmailAddress.indexOf("@")) return false;
	//"@" must not be the first or last character
	if(EmailAddress.indexOf("@")==0 || EmailAddress.lastIndexOf("@")==len-1 ) return false;
	if(EmailAddress.indexOf("@.")>-1) return false;
	//"." must be not the first or last character
	if(EmailAddress.indexOf(".")==0 || EmailAddress.lastIndexOf(".")==len-1 ) return false;
	//OK
	return true;
}
/*
图片缩放函数
参数说明:
	ImgD --图片地址
	width --目标宽度
	height --目标高度
*/
var flag=false;
function DrawImage(ImgD,width,height){
    var image=new Image();
    var iwidth =width;  //定义允许图片宽度
    var iheight =height;  //定义允许图片高度
    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;
        }
    }
} 

/*
函数:Allcheck
作用:用于(全选/取消全选)
参数说明:form --表单名
*/
function Allcheck(form)
{
  for(var i=0;i<form.elements.length;i++)
  {
   var e=form.elements[i];
    if(e.name!="checkall")
	{
	  e.checked = form.checkall.checked;
	}
  }
}

/*
函数:ChangeImage
参数说明:
imgpath --图片地址
2005-6-9 郭立江
*/
var imagego=false;
function ChangeImage(imgpath)
  {
  	var image=new Image();
	image.src=imgpath;
	if((image.width>0)&&(image.height>0))
	{
		if((image.width>500)||(image.height>400))
		{
			alert("为了保证您的信息能被访问者迅速浏览,建议您上传的图片大小不要超过500*400,\n该图片大小为:"+image.width+"*"+image.height+"!\n图片修改之后,建议重命名,再上传!");
			imagego=false;
		}
		else
		{
			 var arrstr=new Array();
			 arrstr=imgpath.split(".")
			 var len=arrstr.length;
			 var strext=arrstr[len-1].toLowerCase();
			 if(strext=="gif"||strext=="jpg")
			 {
				imagego=true;
			 }
			 else
			 {
				alert("图片格式不正确,只允许上传JPG或GIF图片");
				imagego=false;
			 }
		}
	}
	else
	{
		imagego=false;
	}
	return imagego;
  }

var Chkgo=false;
function CheckWord(filepath)
{
	if(filepath!="")
	{
		lowerext=filepath.substring(filepath.length-4,filepath.length);
		lowerext=lowerext.toLowerCase();
		if ((lowerext!=".doc")&&(lowerext!=".txt"))
		{
			alert("上传格式不正确,只允许上传doc或txt图片");
			Chkgo=false;
		}
		else
		{
			Chkgo=true;
		}
	}
	return Chkgo;
}
/*
函数:CheckDel()
作用:用于确定是否删除
*/
function CheckDel()
{
	if(confirm("你确定要删除吗?"))
	{
		return true;
	}
	else
	{
		return false;
	}
}


function switchSysBar(){
	
		
		document.all("frmTitle").style.display="none"
		document.all("frmTitle1").style.display=""
	

}
function switchSysBar1(){
	
		
		document.all("frmTitle1").style.display="none"
		document.all("frmTitle").style.display=""

	
}
function expandTree(treeName) {
	if (treeName == "") return;
	
	//var treeButton2 = eval(treeName + "button2");
	var treesub = eval(treeName + "sub");
	if (treesub.style.display == "none") {
		activeTree = "";
		expandTree(activeTree);  //这里是再次用这个函数来使以前出来的菜单隐藏,即每次只有一个菜单显示。
		
		//treeButton2.src = "../../images/fopen.gif";
		treesub.style.display = "";   //display共有四个属性值:block,inline,list-item,none;如果不是none,那么默认为显示.(在下面的display中定义)
		activeTree = treeName;
	} else {
		
		//treeButton2.src = "../../images/fclose.gif";
		treesub.style.display = "none";
		activeTree = "";
	}
	
}
function changebg(objname,stylename)
{var delTD = document.getElementById(objname);
delTD.className = stylename;
}

/* 	
	函数:CheckLen()
	作用:检查字符串长度;一个中文算2个字符
	参数说明:str --字符串
			  strlen --限制字符长度
			  word --说明文字!
	2005-7-29 guolijiang
*/
function CheckLen(str,strlen,word)
{
	var len=str.length;
	var j=0;
	for(var i=0;i<len;i++)
	{
		var charcode=str.charCodeAt(i);
		if(charcode<=8192)
		{
			j++;
		}
		else
		{
			j+=2;
		}
	}
	if(j>strlen)
	{
		alert(word+"字符不要超过"+strlen+"个!一个汉字算2个字符!当前字符"+j+"!")
		return false;
	}
	else
	{
		return true;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -