js 段典藏

//检测字符串中所有字符是不是数字
function CheckNum(NUM)
{
 var i,j,strTemp;
 strTemp="0123456789";
 if ( NUM.length== 0)
  return 0
 for (i=0;i<NUM.length;i++)
 {
  j=strTemp.indexOf(NUM.charAt(i)); 
  if (j==-1)
  {
  //说明有字符不是数字
   return 0;
  }
 }
 //说明是数字
 return 1;
}

//检测字符中是不是由数字,英文和下划线阻成
function CheckUser(NUM)
{
 var i,j,strTemp;
 strTemp="0123456789-ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz";
 if ( NUM.length== 0)
  return 0
 for (i=0;i<NUM.length;i++)
 {
  j=strTemp.indexOf(NUM.charAt(i)); 
  if (j==-1)
  {
  //说明有字符不是数字,字母或是下划线
   return 0;
  }
 }
 //说明是数字,字母或是下划线
 return 1;
}

//检测字符中有没有特殊字符
function CheckMember(str){
 var i,j,strTemp;
 strTemp="~!@#$%^&*':?><+|"
 if (str.length==0)
  return 0
 for (i=0;i<str.length;i++){
  j=strTemp.indexOf(str.charAt(i));
  if(j==1){
  //说明字符串中有特殊字符
   return 0;
  }
 }
 //说明字符串中没有特殊字符
 return 1;
}

//检测小图的宽高,以合适的规格显示
function featsize(pic){
 //alert("ok");
 var width=pic.width;    //得到图片的实际宽
 var height=pic.height;    //得到图片的实际高
 var scale;       //缩小比例
 
 if (width>128||height>128){   //图片宽和高都超过128px
  //alert("ok1");
  if (width>height){    //图片的宽大于高,取图片宽为128px,高按比例缩小
   scale=128/width;
   height=height*scale;
   pic.width=128;
   pic.height=Math.floor(height);
  }
  else       //图片的高大于宽,取图片高为128px,宽按比例缩小
   scale=128/height;
   width=width*scale;
   pic.width=Math.floor(width);
   //alert("ok2");
   pic.height=128;
 }
 
}

//图片缩小
function smallit(){           
 var height1=document.images1.height;           
 var width1=document.images1.width;           
 document.images1.height=height1/1.2;           
 document.images1.width=width1/1.2;          
}            

//图片放大
function bigit(){           
 var height1=document.images1.height;           
 var width1=document.images1.width;           
 document.images1.height=height1*1.2;         
 document.images1.width=width1*1.2;          

//实际大小
function realsize(){
 document.images1.height=document.images2.height;    
 document.images1.width=document.images2.width;
 //document.block1.style.left = 0;
 //document.block1.style.top = 0;
 
}

//合适大小
function featsize1(){
 var width1=document.images2.width;           
 var height1=document.images2.height;           
 var width2=772;           
 var height2=499;           
 var h=height1/height2;
 var w=width1/width2;
 if(height1<height2&&width1<width2){
  document.images1.height=height1;           
  document.images1.width=width1;          
 }
 else{
  if(h>w){
   document.images1.height=height2;         
   document.images1.width=width1*height2/height1;          
  }
  else{
   document.images1.width=width2;          
   document.images1.height=height1*width2/width1;         
  }
 }
 document.block1.style.left = 0;
 document.block1.style.top = 0;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值