• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
安安的BLOG
安安目前专注电子商务解决方案^_^
博客园    首页    新随笔    联系   管理    订阅  订阅

在b/s开发中经常用到的javaScript技术(转载3)

screen.width/2)this.width=screen.width/2 vspace=2 border=0>ownload ID=include STYLE=behavior:url(#default#download) />
<title>Chromeless Window</title>
<SCRIPT LANGUAGE=JScript>
/*--- Special Thanks For andot ---*/
/*
 This following code are designed and writen by Windy_sk <seasonx@163.net>
 You can use it freely, but u must held all the copyright items!
*/
/*--- Thanks For andot Again ---*/
var CW_width = 400;
var CW_height = 300;
var CW_top = 100;
var CW_left = 100;
var CW_url = /;
var New_CW = window.createPopup();
var CW_Body = New_CW.document.body;
var content = ;
var CSStext = margin:1px;color:black; border:2px outset;border-style:expression(onmouseout=onmouseup=function(){this.style.borderStyle='outset'}, onmousedown=function(){if(event.button!=2)this.style.borderStyle='inset'});background-color:buttonface;width:16px;height:14px;font-size:12px;line-height:11px;cursorscreen.width/2)this.width=screen.width/2 vspace=2 border=0>efault;;
//Build Window
include.startDownload(CW_url, function(source){content=source});
function insert_content(){
 var temp = ;
 CW_Body.style.overflow  = hidden;
 CW_Body.style.backgroundColor = white;
 CW_Body.style.border  =  solid black 1px;
 content = content.replace(/<a ([^>]*)>/g,<a onclick='parent.open(this.href);return false' $1>screen.width/2)this.width=screen.width/2 vspace=2 border=0>;
 temp += <table width=100% height=100% cellpadding=0 cellspacing=0 border=0>;
 temp += <tr style=';font-size:12px;background:#0099CC;height:20;cursor:default' ondblclick=\Max.innerText=Max.innerText=='1'?'2':'1';parent.if_max=!parent.if_max;parent.show_CW();\ onmouseup='parent.drag_up(event)' onmousemove='parent.drag_move(event)' onmousedown='parent.drag_down(event)' onselectstart='return false' oncontextmenu='return false'>;
 temp += <td style='color:#ffffff;padding-left:5px'>Chromeless Window For IE6 SP1</td>;
 temp += <td style='color:#ffffff;padding-right:5px;' align=right>;
 temp += <span id=Help  onclick=\alert('Chromeless Window For IE6 SP1  -  Ver 1.0\\n\\nCode By Windy_sk\\n\\nSpecial Thanks For andot')\ style=\+CSStext+font-family:System;padding-right:2px;\>?</span>;
 temp += <span id=Min   onclick='parent.New_CW.hide();parent.blur()' style=\+CSStext+font-family:Webdings;\ title='Minimum'>0</span>;
 temp += <span id=Max   onclick=\this.innerText=this.innerText=='1'?'2':'1';parent.if_max=!parent.if_max;parent.show_CW();\ style=\+CSStext+font-family:Webdings;\ title='Maximum'>1</span>;
 temp += <span id=Close onclick='parent.opener=null;parent.close()' style=\+CSStext+font-family:System;padding-right:2px;\ title='Close'>x</span>;
 temp += </td></tr><tr><td colspan=2>;
 temp += <div id=include style='overflow:scroll;overflow-x:hidden;overflow-y:auto; HEIGHT: 100%; width:+CW_width+'>;
 temp += content;
 temp += </div>;
 temp += </td></tr></table>;
 CW_Body.innerHTML = temp;
}
setTimeout(insert_content(),1000);
var if_max = true;
function show_CW(){
 window.moveTo(10000, 10000);
 if(if_max){
  New_CW.show(CW_top, CW_left, CW_width, CW_height);
  if(typeof(New_CW.document.all.include)!=undefinedscreen.width/2)this.width=screen.width/2 vspace=2 border=0>{
   New_CW.document.all.include.style.width = CW_width;
   New_CW.document.all.Max.innerText = 1;
  }
 
 }else{
  New_CW.show(0, 0, screen.width, screen.height);
  New_CW.document.all.include.style.width = screen.width;
 }
}
window.onfocus  = show_CW;
window.onresize = show_CW;
// Move Window
var drag_x,drag_y,draging=false
function drag_move(e){
 if (draging){
  New_CW.show(e.screenX-drag_x, e.screenY-drag_y, CW_width, CW_height);
  return false;
 }
}
function drag_down(e){
 if(e.button==2)return;
 if(New_CW.document.body.offsetWidth==screen.width && New_CW.document.body.offsetHeight==screen.height)return;
 drag_x=e.clientX;
 drag_y=e.clientY;
 draging=true;
 e.srcElement.setCapture();
}
function drag_up(e){
 draging=false;
 e.srcElement.releaseCapture();
 if(New_CW.document.body.offsetWidth==screen.width && New_CW.document.body.offsetHeight==screen.height) return;
 CW_top  = e.screenX-drag_x;
 CW_left = e.screenY-drag_y;
}
</SCRIPT>
</HTML>
电话号码的验证
要求:
  (1)电话号码由数字、(、screen.width/2)this.width=screen.width/2 vspace=2 border=0>和-构成
  (2)电话号码为3到8位
  (3)如果电话号码中包含有区号,那么区号为三位或四位
  (4)区号用(、screen.width/2)this.width=screen.width/2 vspace=2 border=0>或-和其他部分隔开
  (5)移动电话号码为11或12位,如果为12位,那么第一位为0
  (6)11位移动电话号码的第一位和第二位为13
  (7)12位移动电话号码的第二位和第三位为13
  根据这几条规则,可以与出以下正则表达式:
  (^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)
<script language=javascript>
function PhoneCheck(s) {
var str=s;
var reg=/(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/
alert(reg.test(str));
}

<input type=text name=iphone>
<input type=button onclick=PhoneCheck(document.all.iphone.value) value=Check>
具有在输入非数字字符不回显的效果,即对非数字字符的输入不作反应。
function numbersonly(field,event){
 var key,keychar;
 if(window.event){
  key = window.event.keyCode;
 }
 else if (event){
  key = event.which;
 }
 else{
  return true
 }
 keychar = String.fromCharCode(key);
 if((key == null)||(key == 0)||(key == 8)||(key == 9)||(key == 13)||(key == 27)){
  return true;
 }
 else if((0123456789.screen.width/2)this.width=screen.width/2 vspace=2 border=0>.indexOf(keychar)>-1){
  window.status = ;
  return true;
 }
 else {
  window.status = Field excepts numbers only;
  return false;
 }
}
验证ip
str=document.RegExpDemo.txtIP.value;
if(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.test(str)==false)
{
 window.alert('错误的IP地址格式');
 document.RegExpDemo.txtIP.select();
 document.RegExpDemo.txtIP.focus();
 return;
}
if(RegExp.$1<1 || RegExp.$1>254||RegExp.$2<0||RegExp.$2>254||RegExp.$3<0||RegExp.$3>254||RegExp.$4<1||RegExp.$4>254)
{
 window.alert('错误的IP地址');
 document.RegExpDemo.txtIP.select();
 document.RegExpDemo.txtIP.focus();
 return;
}
//剔除 如  010.020.020.03 前面 的0
var str=str.replace(/0(\d)/g,$1screen.width/2)this.width=screen.width/2 vspace=2 border=0>;
str=str.replace(/0(\d)/g,$1screen.width/2)this.width=screen.width/2 vspace=2 border=0>;
window.alert(str);
//一下是取数据的类
//Obj参数指定数据的来源(限定Table),默认第一行为字段名称行
//GetTableData类提供MoveNext方法,参数是表的行向上或向下移动的位数,正数向下移动,负数向上.
//GetFieldData方法获得指定的列名的数据
//Sort_desc方法对指定的列按降序排列
//Sort_asc方法对指定的列按升序排列
//GetData方法返回字段值为特定值的数据数组,提供数据,可以在外部进行其他处理
//Delete方法删除当前记录,数组减少一行
//初始化,Obj:table的名字,Leftlen:左面多余数据长度,Rightlen:右面多余数据长度,
function GetTableData(Obj,LeftLen,RightLen){
var MyObj=document.all(Obj);
var iRow=MyObj.rows.length;
var iLen=MyObj.rows[0].cells.length;
var i,j;
TableData=new Array();
  for (i=0;i< iRow;i++){
   TableData[i]=new Array();
   for (j=0;j<iLen;j++){
   TableStr=MyObj.rows(i).cells(j).innerText;
   TableStr=TableStr.substring(LeftLen, TableStr.length-RightLen).Trim();
   TableStr=TableStr.replace(/ /gi

posted @ 2006-02-25 15:32  安安  阅读(188)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3