js字符串去空白、取子串以及js打开窗口

<html>
 <head>
  <title>测试字符串</title>
  <script>

//去空白prototype
   String.prototype.trim = function() { 
    return this.replace(/(^\s*)|(\s*$)/g, "");  
   }
   //去空白方法
   function trim(str) { 
    return str.replace(/(^\s*)|(\s*$)/, "");  
   }
   
   var s = "    123uuuuu     ";
   alert(s.slice(4, 11));
   alert(s.slice(4, 11).length);
   alert(s.length);
   alert(s.trim().length);
   alert(trim(s).length);
   alert(trim(s));
   
   var phoneNumOrg = "(130) 51570789";
   if(phoneNumOrg != null && phoneNumOrg != "" && phoneNumOrg.length >= 7){
    var phoneNum = phoneNumOrg.slice(1,4) + phoneNumOrg.slice(6);
    alert("phoneNum: " + phoneNum);
   }
   
   function openModelSMSWin(){
    var url="http://www.baidu.com";
    var nLeft = ( window.screen.width + 300 )/2;
    var nTop = ( window.screen.height - 200 )/2;
    var sStyle="width=430px,height=290px,left="+nLeft+"px,top="+nTop+"px,scrollbars=no,resizable=no,menubar=no,status=no, location=no";
    window.open(url,"即时短信", sStyle);
   } 
  </script>
 </head>
 <body>
  <input type="button" value="模板" οnclick="openModelSMSWin();" />
 </body>
</html>

 

js字符串大小写转换

var str = "aaaa";

alert(str.toLowerCase());

alert(str.toUpperCase());

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值