常用js脚本

/*随机数字(0~limit之间的随机数包含0和不包含limit)*/
function randomNumber(limit){
  
return Math.floor(Math.random()*limit);
}
/*冒泡排序*/
function bubbleSort(theArray)
{
  
var i, j;
  
for (i = theArray.length - 1; i >= 0; i--)
  {
    
for (j = 0; j <= i; j++)
    {
      
if (theArray[j+1< theArray[j])
      {
        
var temp = theArray[j];
        theArray[j] 
= theArray[j+1];
        theArray[j
+1= temp;
      }
    }
  }
  
return theArray;
}
/*字符替换*/
function replaceCharacters(conversionString,inChar,outChar)
{
  
var convertedString = conversionString.split(inChar);
  convertedString 
= convertedString.join(outChar);
  
return convertedString;
}
/*信息窗口*/
var msgWindow = null;
function messageWindow(title, msg)
{
  
var width="300", height="125";
  
var left = (screen.width/2- width/2;
  
var top = (screen.height/2- height/2;
  
var styleStr = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+',top='+top+',screenX='+left+',screenY='+top;
  
if(msgWindow==null){
      msgWindow 
= window.open("","msgWindow", styleStr);
      
var head = '<head><title>'+title+'</title></head>';
      
var body = '<center>'+msg+'<br><p><form><input type="button" value="   Done   " onClick="self.close()"></form>';
      msgWindow.document.write(head 
+ body);
  }
}
/*弹出窗口*/
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  
if(popUpWin)
  {
    
if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin 
= open(URLStr, 'popUpWin''toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}
/*确认*/
confirm(messageStr);
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值