一、验证类
1、数字验证内
1.1 整数
1.2 大于0的整数 (用于传来的ID的验证)
1.3 负整数的验证
1.4 整数不能大于iMax
1.5 整数不能小于iMin
2、时间类
2.1 短时间,形如 (13:04:06)
2.2 短日期,形如 (2003-12-05)
2.3 长时间,形如 (2003-12-05 13:04:06)
2.4 只有年和月。形如(2003-05,或者2003-5)
2.5 只有小时和分钟,形如(12:03)
3、表单类
3.1 所有的表单的值都不能为空
3.2 多行文本框的值不能为空。
3.3 多行文本框的值不能超过sMaxStrleng
3.4 多行文本框的值不能少于sMixStrleng
3.5 判断单选框是否选择。
3.6 判断复选框是否选择.
3.7 复选框的全选,多选,全不选,反选
3.8 文件上传过程中判断文件类型
4、字符类
4.1 判断字符全部由a-Z或者是A-Z的字字母组成
4.2 判断字符由字母和数字组成。
4.3 判断字符由字母和数字,下划线,点号组成.且开头的只能是下划线和字母
4.4 字符串替换函数.Replace();
5、浏览器类
5.1 判断浏览器的类型
5.2 判断ie的版本
5.3 判断客户端的分辨率
6、结合类
6.1 email的判断。
6.2 手机号码的验证
6.3 身份证的验证
二、功能类
1、时间与相关控件类
1.1 日历
1.2 时间控件
1.3 万年历
1.4 显示动态显示时钟效果(文本,如OA中时间)
1.5 显示动态显示时钟效果 (图像,像手表)
2、表单类
2.1 自动生成表单
2.2 动态添加,修改,删除下拉框中的元素
2.3 可以输入内容的下拉框
2.4 多行文本框中只能输入iMax文字。如果多输入了,自动减少到iMax个文字(多用于短信发送)
3、打印类
3.1 打印控件
4 事件类
4.1 屏蔽右键
4.2 屏蔽所有功能键
4.3 --> 和<-- F5 F11,F9,F1
4.4 屏蔽组合键ctrl+N
5、网页设计类
5.1 连续滚动的文字,图片(注意是连续的,两段文字和图片中没有空白出现)
5.2 html编辑控件类
5.3 颜色选取框控件
5.4 下拉菜单
5.5 两层或多层次的下拉菜单
5.6 仿IE菜单的按钮。(效果如rongshuxa.com的导航栏目)
5.7 状态栏,title栏的动态效果(例子很多,可以研究一下)
5.8 双击后,网页自动滚屏
6、树型结构。
6.1 asp+SQL版
6.2 asp+xml+sql版
6.3 java+sql或者java+sql+xml
7、无边框效果的制作
8、连动下拉框技术
9、文本排序
++++++++++++++++++++++++++++++++++++++++++++++++++++
一、验证类
1、数字验证内
1.1 整数
/^(-|/+)?/d+$/.test(str)
1.2 大于0的整数 (用于传来的ID的验证)
/^/d+$/.test(str)
1.3 负整数的验证
/^-/d+$/.test(str)
2、时间类
2.1 短时间,形如 (13:04:06)
function isTime(str)
{
var a = str.match(/^(/d{1,2})(:)?(/d{1,2})/2(/d{1,2})$/);
if (a == null) {alert('输入的参数不是时间格式'); return false;}
if (a[1]>24 || a[3]>60 || a[4]>60)
{
alert("时间格式不对");
return false
}
return true;
}
2.2 短日期,形如 (2003-12-05)
function strDateTime(str)
{
var r = str.match(/^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2})$/);
if(r==null)return false;
var d= new Date(r[1], r[3]-1, r[4]);
return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);
}
2.3 长时间,形如 (2003-12-05 13:04:06)
function strDateTime(str)
{
var reg = /^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2}) (/d{1,2}):(/d{1,2}):(/d{1,2})$/;
var r = str.match(reg);
if(r==null)return false;
var d= new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]);
return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]);
}
2.4 只有年和月。形如(2003-05,或者2003-5)
2.5 只有小时和分钟,形如(12:03)
3、表单类
3.1 所有的表单的值都不能为空
<input οnblur="if(this.value.replace(/^/s+|/s+$/g,'')=='')alert('不能为空!')">
3.2 多行文本框的值不能为空。
3.3 多行文本框的值不能超过sMaxStrleng
3.4 多行文本框的值不能少于sMixStrleng
3.5 判断单选框是否选择。
3.6 判断复选框是否选择.
3.7 复选框的全选,多选,全不选,反选
3.8 文件上传过程中判断文件类型
4、字符类
4.1 判断字符全部由a-Z或者是A-Z的字字母组成
<input οnblur="if(/[^a-zA-Z]/g.test(this.value))alert('有错')">
4.2 判断字符由字母和数字组成。
<input οnblur="if(/[^0-9a-zA-Z]/g.test(this.value))alert('有错')">
4.3 判断字符由字母和数字,下划线,点号组成.且开头的只能是下划线和字母
/^([a-zA-z_]{1})([/w]*)$/g.test(str)
4.4 字符串替换函数.Replace();
5、浏览器类
5.1 判断浏览器的类型
window.navigator.appName
5.2 判断ie的版本
window.navigator.appVersion
5.3 判断客户端的分辨率
window.screen.height; window.screen.width;
6、结合类
6.1 email的判断。
function ismail(mail)
{
return(new RegExp(/^/w+((-/w+)|(/./w+))*/@[A-Za-z0-9]+((/.|-)[A-Za-z0-9]+)*/.[A-Za-z0-9]+$/).test(mail));
}
6.2 手机号码的验证
6.3 身份证的验证
function isIdCardNo(num)
{
if (isNaN(num)) {alert("输入的不是数字!"); return false;}
var len = num.length, re;
if (len == 15)
re = new RegExp(/^(/d{6})()?(/d{2})(/d{2})(/d{2})(/d{3})$/);
else if (len == 18)
re = new RegExp(/^(/d{6})()?(/d{4})(/d{2})(/d{2})(/d{3})(/d)$/);
else {alert("输入的数字位数不对!"); return false;}
var a = num.match(re);
if (a != null)
{
if (len==15)
{
var D = new Date("19"+a[3]+"/"+a[4]+"/"+a[5]);
var B = D.getYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];
}
else
{
var D = new Date(a[3]+"/"+a[4]+"/"+a[5]);
var B = D.getFullYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];
}
if (!B) {alert("输入的身份证号 "+ a[0] +" 里出生日期不对!"); return false;}
}
return true;
}
4 事件类
4.1 屏蔽右键
在body标签里加上οncοntextmenu=self.event.returnValue=false
4.2 屏蔽所有功能键
4.3 --> 和<-- F5 F11,F9,F1
4.4 屏蔽组合键ctrl+N
<script language=javascript>
function KeyDown(){
if ((window.event.altKey)&&
((window.event.keyCode==37)|| //屏蔽 Alt+ 方向键 ←
(window.event.keyCode==39))){ //屏蔽 Alt+ 方向键 →
alert("不准你使用ALT+方向键前进或后退网页!");
event.returnValue=false;
}
if ((event.keyCode==8)|| //屏蔽退格删除键
(event.keyCode==116)){ //屏蔽 F5 刷新键
event.keyCode=0;
event.returnValue=false;
}
if ((event.ctrlKey)&&(event.keyCode==78)){ //屏蔽 Ctrl+n
event.returnValue=false;
}
if ((event.shiftKey)&&(event.keyCode==121)){ //屏蔽 shift+F10
event.returnValue=false;
}
if (event.keyCode==122){ //屏蔽 F11
event.returnValue=false;
}
}
只要知道keyCode即可屏蔽所有功能键
3.7 复选框的全选,多选,全不选,反选
<form name=hrong>
<input type=checkbox name=All οnclick="checkAll('mm')">全选<br/>
<input type=checkbox name=mm οnclick="checkItem('All')"><br/>
<input type=checkbox name=mm οnclick="checkItem('All')"><br/>
<input type=checkbox name=mm οnclick="checkItem('All')"><br/>
<input type=checkbox name=mm οnclick="checkItem('All')"><br/>
<input type=checkbox name=mm οnclick="checkItem('All')"><br/><br/>
<input type=checkbox name=All2 οnclick="checkAll('mm2')">全选<br/>
<input type=checkbox name=mm2 οnclick="checkItem('All2')"><br/>
<input type=checkbox name=mm2 οnclick="checkItem('All2')"><br/>
<input type=checkbox name=mm2 οnclick="checkItem('All2')"><br/>
<input type=checkbox name=mm2 οnclick="checkItem('All2')"><br/>
<input type=checkbox name=mm2 οnclick="checkItem('All2')"><br/>
</form>
<SCRIPT LANGUAGE="JavaScript">
function checkAll(str)
{
var a = document.getElementsByName(str);
var n = a.length;
for (var i=0; i<n; i++)
a[i].checked = window.event.srcElement.checked;
}
function checkItem(str)
{
var e = window.event.srcElement;
var all = eval("document.hrong."+ str);
if (e.checked)
{
var a = document.getElementsByName(e.name);
all.checked = true;
for (var i=0; i<a.length; i++)
{
if (!a[i].checked){ all.checked = false; break;}
}
}
else all.checked = false;
}
</SCRIPT>
3.8 文件上传过程中判断文件类型
<input type=file οnchange="alert(this.value.match(/^(.*)(/.)(.{1,8})$/)[3])">
画图:
<OBJECT
id=S
style="LEFT: 0px; WIDTH: 392px; TOP: 0px; HEIGHT: 240px"
height=240
width=392
classid="clsid:369303C2-D7AC-11D0-89D5-00A0C90833E6">
</OBJECT>
<SCRIPT>
S.DrawingSurface.ArcDegrees(0,0,0,30,50,60);
S.DrawingSurface.ArcRadians(30,0,0,30,50,60);
S.DrawingSurface.Line(10,10,100,100);
</SCRIPT>
写注册表:
<SCRIPT>
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.RegWrite ("HKCU//Software//ACME//FortuneTeller//", 1, "REG_BINARY");
WshShell.RegWrite ("HKCU//Software//ACME//FortuneTeller//MindReader", "Goocher!", "REG_SZ");
var bKey = WshShell.RegRead ("HKCU//Software//ACME//FortuneTeller//");
WScript.Echo (WshShell.RegRead ("HKCU//Software//ACME//FortuneTeller//MindReader"));
WshShell.RegDelete ("HKCU//Software//ACME//FortuneTeller//MindReader");
WshShell.RegDelete ("HKCU//Software//ACME//FortuneTeller//");
WshShell.RegDelete ("HKCU//Software//ACME//");
</SCRIPT>
TABLAE相关(客户端动态增加行列)
<HTML>
<SCRIPT LANGUAGE="JScript">
function numberCells() {
var count=0;
for (i=0; i < document.all.mytable.rows.length; i++) {
for (j=0; j < document.all.mytable.rows(i).cells.length; j++) {
document.all.mytable.rows(i).cells(j).innerText = count;
count++;
}
}
}
</SCRIPT>
<BODY οnlοad="numberCells()">
<TABLE id=mytable border=1>
<TR><TH> </TH><TH> </TH><TH> </TH><TH> </TH></TR>
<TR><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR>
<TR><TD> </TD><TD> </TD><TD> </TD><TD> </TD></TR>
</TABLE>
</BODY>
</HTML>
呵呵,黄蓉也来了,我也来补充一个.
1.身份证严格验证:
<script>
var aCity={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"}
function cidInfo(sId){
var iSum=0
var info=""
if(!/^/d{17}(/d|x)$/i.test(sId))return false;
sId=sId.replace(/x$/i,"a");
if(aCity[parseInt(sId.substr(0,2))]==null)return "Error:非法地区";
sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2));
var d=new Date(sBirthday.replace(/-/g,"/"))
if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))return "Error:非法生日";
for(var i = 17;i>=0;i --) iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 - i),11)
if(iSum%11!=1)return "Error:非法证号";
return aCity[parseInt(sId.substr(0,2))]+","+sBirthday+","+(sId.substr(16,1)%2?"男":"女")
}
document.write(cidInfo("380524198002300016"),"<br/>");
document.write(cidInfo("340524198002300019"),"<br/>")
document.write(cidInfo("340524197711111111"),"<br/>")
document.write(cidInfo("34052419800101001x"),"<br/>");
</script>
2.验证IP地址
<SCRIPT LANGUAGE="JavaScript">
function isip(s){
var check=function(v){try{return (v<=255 && v>=0)}catch(x){return false}};
var re=s.split(".")
return (re.length==4)?(check(re[0]) && check(re[1]) && check(re[2]) && check(re[3])):false
}
var s="202.197.78.129";
alert(isip(s))
</SCRIPT>
3.加sp1后还能用的无边框窗口!!
<HTML XMLNS:IE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<IE:Download 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(οnmοuseοut=οnmοuseup=function(){this.style.borderStyle='outset'}, οnmοusedοwn=function(){if(event.button!=2)this.style.borderStyle='inset'});background-color:buttonface;width:16px;height:14px;font-size:12px;line-height:11px;cursor:Default;";
//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 οnclick='parent.open(this.href);return false' $1>");
temp += "<table width=100% height=100% cellpadding=0 cellspacing=0 border=0>";
temp += "<tr style=';font-size:12px;background:#0099CC;height:20;cursor:default' οndblclick=/"Max.innerText=Max.innerText=='1'?'2':'1';parent.if_max=!parent.if_max;parent.show_CW();/" οnmοuseup='parent.drag_up(event)' οnmοusemοve='parent.drag_move(event)' οnmοusedοwn='parent.drag_down(event)' onselectstart='return false' οncοntextmenu='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 οnclick=/"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 οnclick='parent.New_CW.hide();parent.blur()' style=/""+CSStext+"font-family:Webdings;/" title='Minimum'>0</span>";
temp += "<span id=Max οnclick=/"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 οnclick='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)!="undefined"){
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)电话号码由数字、"("、")"和"-"构成
(2)电话号码为3到8位
(3)如果电话号码中包含有区号,那么区号为三位或四位
(4)区号用"("、")"或"-"和其他部分隔开
(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));
}
</script>
<input type=text name="iphone">
<input type=button οnclick="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.").indexOf(keychar)>-1){
window.status = "";
return true;
}
else {
window.status = "Field excepts numbers only";
return false;
}
}
有时候还需要自由编辑表格---
给大家一个自由编辑表格的小例子,写的有点乱,呵呵:)
//===============================start================================
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<TITLE>测试修改表格</TITLE>
<STYLE>
/*提示层的样式*/
div
{
BORDER-RIGHT: #80c144 1px solid;
BORDER-TOP: #80c144 1px solid;
VISIBILITY: hidden;
BORDER-LEFT: #80c144 1px solid;
CURSOR: default;
LINE-HEIGHT: 20px;
BORDER-BOTTOM: #80c144 1px solid;
FONT-FAMILY: 宋体;
font-size:12px;
POSITION: absolute;
BACKGROUND-COLOR: #f6f6f6;
TOP:30px;
LEFT:30px;
}
/*tr的样式*/
tr
{
font-family: "宋体";
color: #000000;
background-color: #C1DBF5;
font-size: 12px
}
/*table脚注样式*/
.TrFoot
{
FONT-SIZE: 12px;
font-family:"宋体", "Verdana", "Arial";
BACKGROUND-COLOR: #6699CC;
COLOR:#FFFFFF;
height: 25;
}
/*trhead属性*/
.TrHead
{
FONT-SIZE: 13px;
font-family:"宋体", "Verdana", "Arial";
BACKGROUND-COLOR: #77AADD;
COLOR:#FFFFFF;
height: 25;
}
/*文本框样式*/
INPUT
{
BORDER-COLOR: #AACEF7 #AACEF7 #AACEF7 #AACEF7;
BORDER-RIGHT: 1px solid;
BORDER-TOP: 1px solid;
BORDER-LEFT: 1px solid;
BORDER-BOTTOM: 1px solid;
FONT-SIZE: 12px;
FONT-FAMILY: "宋体","Verdana";
color: #000000;
BACKGROUND-COLOR: #E9EFF5;
}
/*button样式*/
button
{
BORDER-COLOR: #AACEF7 #AACEF7 #AACEF7 #AACEF7;
BACKGROUND-COLOR: #D5E4F3;
CURSOR: hand;
FONT-SIZE:12px;
BORDER-RIGHT: 1px solid;
BORDER-TOP: 1px solid;
BORDER-LEFT: 1px solid;
BORDER-BOTTOM: 1px solid;
COLOR: #000000;
}
</STYLE>
</HEAD>
<BODY>
<SCRIPT language = "JavaScript">
<!--全局变量
//标志位,值为false代表未打开一个编辑框,值为true为已经打开一个编辑框开始编辑
var editer_table_cell_tag = false;
//开启编辑功能标志,值为true时为允许编辑
var run_edit_flag = false;
//-->
</SCRIPT>
<SCRIPT language = "JavaScript">
<!--
/**
* 编辑表格函数
* 单击某个单元格可以对里面的内容进行自由编辑
* @para tableID 为要编辑的table的id
* @para noEdiID 为不要编辑的td的ID,比如说table的标题
* 可以写为<TD id="no_editer">自由编辑表格</TD>
* 此时该td不可编辑
*/
function editerTableCell(tableId,noEdiId)
{
var tdObject = event.srcElement;
var tObject = ((tdObject.parentNode).parentNode).parentNode;
if(tObject.id == tableId &&tdObject.id != noEdiId&&editer_table_cell_tag == false && run_edit_flag == true)
{
tdObject.innerHTML = "<input type=text id=edit_table_txt name=edit_table_txt value="+tdObject.innerText+" size='15' onKeyDown='enterToTab()'> <input type=button value=' 确定 ' οnclick='certainEdit()'>";
edit_table_txt.focus();
edit_table_txt.select();
editer_table_cell_tag = true;
//修改按钮提示信息
editTip.innerText = "请先点确定按钮确认修改!";
}
else
{
return false;
}
}
/**
* 确定修改
*/
function certainEdit()
{
var bObject = event.srcElement;
var tdObject = bObject.parentNode;
var txtObject = tdObject.firstChild;
tdObject.innerHTML = txtObject.value;
//代表编辑框已经关闭
editer_table_cell_tag = false;
//修改按钮提示信息
editTip.innerText = "请单击某个单元格进行编辑!";
}
function enterToTab()
{
if(event.srcElement.type != 'button' && event.srcElement.type != 'textarea'
&& event.keyCode == 13)
{
event.keyCode = 9;
}
}
/**
* 控制是否编辑
*/
function editStart()
{
if(event.srcElement.value == "开始编辑")
{
event.srcElement.value = "编辑完成";
run_edit_flag = true;
}
else
{
//如果当前没有编辑框,则编辑成功,否则,无法提交
//必须按确定按钮后才能正常提交
if(editer_table_cell_tag == false)
{
alert("编辑成功结束!");
event.srcElement.value = "开始编辑";
run_edit_flag = false;
}
}
}
/**
* 根据不同的按钮提供不同的提示信息
*/
function showTip()
{
if(event.srcElement.value == "编辑完成")
{
editTip.style.top = event.y + 15;
editTip.style.left = event.x + 12;
editTip.style.visibility = "visible";
}
else
{
editTip.style.visibility = "hidden";
}
}
-->
</SCRIPT>
<TABLE id="editer_table" width="100%" align="center"
οnclick="editerTableCell('editer_table','no_editer')">
<TR class="TrHead">
<TD colspan="3" align="center" id="no_editer">自由编辑表格</TD>
</TR>
<TR>
<TD width="33%">单击开始编辑按钮,然后点击各单元格编辑</TD>
<TD width="33%">2</TD>
<TD width="33%">3</TD>
</TR>
<TR>
<TD width="33%">4</TD>
<TD width="33%">5</TD>
<TD width="33%">6</TD>
</TR>
<TR>
<TD width="33%">one</TD>
<TD width="33%">two</TD>
<TD width="33%">three</TD>
</TR>
<TR>
<TD width="33%">four</TD>
<TD width="33%">five</TD>
<TD width="33%">six</TD>
</TR>
<TR class="TrFoot">
<TD colspan="3" align="center" id="no_editer">
<INPUT type="button" class="bt" value="开始编辑" onClick="editStart()" onMouseOver="showTip()" onMouseMove="showTip()" onMouseOut="editTip.style.visibility = 'hidden';">
</TD>
</TR>
</TABLE>
</BODY>
<DIV id="editTip">请单击某个单元格进行编辑!</DIV>
</HTML>
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,"$1");
str=str.replace(/0(/d)/g,"$1");
window.alert(str);
在每个文本框的onblur事件中调用校验代码,并且每个文本框中onKeyDown事件中写一个enter转tab函数
//回车键换为tab
function enterToTab()
{
if(event.srcElement.type != 'button' && event.srcElement.type != 'textarea'
&& event.keyCode == 13)
{
event.keyCode = 9;
}
}
<%
'********************************************
'函数功能:正则表达式校验
'参数patrn:要校验的类型
' "User" - 用户名
' "Truename" - 英文姓名
' "Passwd" - 密码
' "Tel" - 电话/传真
' "Mobil" - 手机
' "Date" - 日期(格式:yyyy-mm-dd)
' "Email" - 电子邮件
' "Postalcode" - 邮政编码
' "Search" - 搜索关键字
' "Int" - 整数
'参数strng:要校验的字串
'返回值:校验结果,正确返回true,错误返回false
'********************************************
Function IsVerify(patrn,strng)
strng=Trim(strng)
Select Case patrn
Case "User" '用户名
patrn="^[a-z]{1}([a-z0-9]|[._]){2,19}$"
Case "Truename" '英文姓名
patrn="^[a-zA-Z]{1,30}$"
Case "Passwd" '密码
patrn="^(/w){6,20}$"
Case "Tel" '电话/传真
patrn="^[+]{0,1}(/d){1,3}[ ]?([-]?((/d)|[ ]){1,12})+$"
Case "Mobil" '手机
patrn="^(/d)+[-]?(/d){6,12}$"
Case "Date" '日期(格式:yyyy-mm-dd)
patrn="^[12]{1}(/d){3}[-][01]?(/d){1}[-][0123]?(/d){1}$"
Case "Email" '电子邮件
patrn="^((/w)|[-]|[.])+@(((/w)|[-])+[.])+[a-z]{2,4}$"
Case "Postalcode" '邮政编码
patrn="^[a-z0-9 ]{3,12}$"
Case "Search" '搜索关键字
patrn="^[^`~!@#$%^&*()+=|///[/]/{/}:;/'/,.<>/?]{1}[^`~!@$%^&()+=|///[/]/{/}:;/'/,.<>?]{0,19}$"
Case "Int" '整数
patrn="^[1-9]{1}[0-9]{0,6}$"
Case "Array"
patrn="^[0-9]{1}([0-9]|[/,]){0,150}$"
End Select
Dim regEx
Dim Match
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
Matches = regEx.test(strng)
IsVerify = Matches
Set regEx = Nothing
End Function
'********************************************
'函数功能:对输入框的特殊字串进行过滤保存
'参数strPass:过滤前的字符串
'返回值:过滤后的字符串
'********************************************
Function SQLencode(byVal strPass)
strPass = Replace(strPass, "&", "&")
strPass = Replace(strPass, "<", "<")
strPass = Replace(strPass, ">", ">")
strPass = Replace(strPass, """", """)
strPass = Replace(strPass, "'", "'")
strPass = Replace(strPass, " ", " ")
strPass = Replace(strPass,chr(13)&chr(10),"<br/>")
SQLencode = strPass
End Function
'********************************************
'函数功能:对SQLencode函数过滤后的字符串进行还原
'参数strPass:经过过滤后的字符串
'返回值:还原的过滤前的字符串
'********************************************
Function SQLdecode(byVal strPass)
If Not isNull(strPass) Then
strPass = Replace(strPass, "<", "<")
strPass = Replace(strPass, ">", ">")
strPass = Replace(strPass, ""","""" )
strPass = Replace(strPass, "'","'" )
strPass = Replace(strPass,"<br/>",chr(13)&chr(10))
End If
SQLdecode = strPass
End Function
'********************************************
'函数功能:生成随机密码(字符为数字与大小写字母集合)
'参数length:密码长度
'返回值:随机密码
'********************************************
Function random(length)
Dim n,str
rnds=""
Randomize
For i=1 To length
n=Int(75*Rnd+48)
If (n>57 and n<65) Or (n>90 and n<97) Then
i=i-1
Else
rnds=rnds&Chr(n)
End If
Next
random=rnds
End Function
'********************************************
'函数功能:对密码进行加密/解密(最大长度为15位)
'********************************************
Function Encrypt(preString)
Dim pwds,s
pwds=""
s=Left(preString,15)
For i=1 To Len(s)
seed=170-Asc(Mid(s,i,1))-i
pwds=pwds & Chr(seed)
Next
Encrypt=pwds
End Function
'********************************************
'函数功能:格式化当前时间字串
'参数:无
'返回值:返回当前时间的纯数字字符串方式的表示(例如:当前时间2001-10-3 2:34:6,返回字符串"20011003023406")
'********************************************
Function TheDate()
y=year(date())
m=month(date())
d=day(date())
h=Hour(time())
n=Minute(time())
s=Second(time())
If Len(m)=1 Then m="0"&m
If Len(d)=1 Then d="0"&d
If Len(h)=1 Then h="0"&h
If Len(n)=1 Then n="0"&n
If Len(s)=1 Then s="0"&s
thedate=y&m&d&h&n&s
End Function
'********************************************
'函数功能:返回字符串的长度
'参数:字符串
'返回值:字符串长度
'********************************************
Function strLen(str)
dim p_len
p_len=0
strlen=0
if trim(str)<>"" then
p_len=len(trim(str))
for xx=1 to p_len
if asc(mid(str,xx,1))<0 then
strlen=int(strlen) + 2
else
strlen=int(strlen) + 1
end if
next
end if
End Function
'********************************************
'函数功能:发送邮件通知
'参数:字符串
'返回值:成功/失败
'********************************************
Function SendMail(ToAddress, Subject, Body)
On Error Resume Next
Set objMail = Server.CreateObject("JMail.Message")
objMail.From = ADR_Email
objMail.FromName = "ADR管理中心"
objMail.Subject = Subject
objMail.AddRecipient ToAddress
objMail.Body = Body
If objMail.Send("") Then
SendMail = True
Else
SendMail = False
End If
If Err.Number<> 0 Then SendMail = False
Set objMail = Nothing
On Error Goto 0
End Function
%>
自己写的一个比较丑的程序,但做报表时候有用
/********************************************************************
时间:2003.7.31
作者:周长武
功能:将阿拉伯数字(小写)转化成中文(大写)
参数:Num为字符型,小数点之后保留两位,例:Arabia_to_Chinese("1234.06")
说明:1.目前本转换仅支持到 拾亿(元) 位,金额单位为元,不能为万元,最小单位为分
2.不支持负数
修改区
时间:
修改人:
原因:
修改区结束
********************************************************************/
function Arabia_to_Chinese(Num){
for(i=Num.length-1;i>=0;i--)
{
Num = Num.replace(",","")//替换tomoney()中的“,”
Num = Num.replace(" ","")//替换tomoney()中的空格
}
Num = Num.replace("¥","")//替换掉可能出现的¥字符
if(isNaN(Num)) { //验证输入的字符是否为数字
alert("请检查小写金额是否正确");
return;
}
//---字符处理完毕,开始转换,转换采用前后两部分分别转换---//
part = String(Num).split(".");
newchar = "";
//小数点前进行转化
for(i=part[0].length-1;i>=0;i--){
if(part[0].length > 10){ alert("位数过大,无法计算");return "";}//若数量超过拾亿单位,提示
tmpnewchar = ""
perchar = part[0].charAt(i);
switch(perchar){
case "0": tmpnewchar="零" + tmpnewchar ;break;
case "1": tmpnewchar="壹" + tmpnewchar ;break;
case "2": tmpnewchar="贰" + tmpnewchar ;break;
case "3": tmpnewchar="叁" + tmpnewchar ;break;
case "4": tmpnewchar="肆" + tmpnewchar ;break;
case "5": tmpnewchar="伍" + tmpnewchar ;break;
case "6": tmpnewchar="陆" + tmpnewchar ;break;
case "7": tmpnewchar="柒" + tmpnewchar ;break;
case "8": tmpnewchar="捌" + tmpnewchar ;break;
case "9": tmpnewchar="玖" + tmpnewchar ;break;
}
switch(part[0].length-i-1){
case 0: tmpnewchar = tmpnewchar +"元" ;break;
case 1: if(perchar!=0)tmpnewchar= tmpnewchar +"拾" ;break;
case 2: if(perchar!=0)tmpnewchar= tmpnewchar +"佰" ;break;
case 3: if(perchar!=0)tmpnewchar= tmpnewchar +"仟" ;break;
case 4: tmpnewchar= tmpnewchar +"万" ;break;
case 5: if(perchar!=0)tmpnewchar= tmpnewchar +"拾" ;break;
case 6: if(perchar!=0)tmpnewchar= tmpnewchar +"佰" ;break;
case 7: if(perchar!=0)tmpnewchar= tmpnewchar +"仟" ;break;
case 8: tmpnewchar= tmpnewchar +"亿" ;break;
case 9: tmpnewchar= tmpnewchar +"拾" ;break;
}
newchar = tmpnewchar + newchar;
}
//小数点之后进行转化
if(Num.indexOf(".")!=-1){
if(part[1].length > 2) {
alert("小数点之后只能保留两位,系统将自动截段");
part[1] = part[1].substr(0,2)
}
for(i=0;i<part[1].length;i++){
tmpnewchar = ""
perchar = part[1].charAt(i)
switch(perchar){
case "0": tmpnewchar="零" + tmpnewchar ;break;
case "1": tmpnewchar="壹" + tmpnewchar ;break;
case "2": tmpnewchar="贰" + tmpnewchar ;break;
case "3": tmpnewchar="叁" + tmpnewchar ;break;
case "4": tmpnewchar="肆" + tmpnewchar ;break;
case "5": tmpnewchar="伍" + tmpnewchar ;break;
case "6": tmpnewchar="陆" + tmpnewchar ;break;
case "7": tmpnewchar="柒" + tmpnewchar ;break;
case "8": tmpnewchar="捌" + tmpnewchar ;break;
case "9": tmpnewchar="玖" + tmpnewchar ;break;
}
if(i==0)tmpnewchar =tmpnewchar + "角";
if(i==1)tmpnewchar = tmpnewchar + "分";
newchar = newchar + tmpnewchar;
}
}
//替换所有无用汉字
while(newchar.search("零零") != -1)
newchar = newchar.replace("零零", "零");
newchar = newchar.replace("零亿", "亿");
newchar = newchar.replace("亿万", "亿");
newchar = newchar.replace("零万", "万");
newchar = newchar.replace("零元", "元");
newchar = newchar.replace("零角", "");
newchar = newchar.replace("零分", "");
if (newchar.charAt(newchar.length-1) == "元" || newchar.charAt(newchar.length-1) == "角")
newchar = newchar+"整"
return newchar;
}
//====================================表单类================================
// 文件上传过程中判断文件类型
/*
<input type=file οnchange="alert(this.value.match(/^(.*)(/.)(.{1,8})$/)[3])">
*/
//表单的值不能为空
function isNull(elem){
//var pattern=/^/s+|/s+$/;
if(elem.replace(/(^/s+|/s$)/g, "")==""){
return false;
}else{
return true;
}
}
//不能超过imax字符
function imax(elem){
if(elem.length>imax){
return false;
}else{
return true;
}
}
//不能少于imix字符
function imix(elem){
if(elem.length<imix){
return false;
}else{
return true;
}
}
//输入为中文判断
function isChinese(elem){
var pattern=/[^/x00-/xff]/g;
if(pattern.test(elem)){
//包含中文
return false;
}else{
//不包含中文
return true;
}
}
/* *********************************************************************************************************************
<html>
<head>
<script language="javascript">
<!--
function isChinese(elem){
var pattern=/[^/x00-/xff]/g;
if(pattern.test(elem)){
//包含中文
return false;
}else{
//不包含中文
return true;
}
}
function isReady(){
if(isChinese(str.chinese.value)==false){
alert("不能输入中文");
str.chinese.focus();
return false;
}
return true;
}
-->
</script>
</head>
<body>
<form name="str" onSubmit="return isReady();">
<input type="text" name="chinese">
<input type="submit" value="中文">
</form>
</body>
</html>
**************************************************************************************************************************** */
// =============================时间类========================================
//短时间(形如: 13:04:06)
//更具弹性的正则表达式:/^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2})$/
function isShortTime(elem){
var pattern=/^([0-9]{1,2})(:)([0-9]{1,2})(:)([0-9]{1,2})$/;
var temp=elem.match(pattern);
if(temp==null)
return false;
if(temp[1]>24)
return false;
if(temp[3]>60)
return false;
if(temp[5]>60)
return false;
return true;
}
//短日期(形如: 2003-12-18)
//更具弹性的正则表达式:/^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2})$/
function isShortDate(elem){
var pattern=/^(/d{4})(-)(/d{2})(-)(/d{2})$/;
var temp=elem.match(pattern);
if(temp==null){
return false;
}
//
var d=new Date(temp[1]+"/"+temp[3]+"/"+temp[5]);
return d.getFullYear()==temp[1]&&
(d.getMonth()+1)==temp[3]&&
d.getDate()==temp[5];
}
//长时间,形如(2003-12-18 13:04:06)
//更具弹性的正则表达示/^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2}) (/d{1,2}):(/d{1,2}):(/d{1,2})$/
function isTime(elem){
var pattern=/^(/d{4})(-)(/d{2})(-)(/d{2})(/s+)(/d{2})(:)(/d{2})(:)(/d{2})$/;
var temp=elem.match(pattern);
if(temp==null) return false;
//date(year,month,date, hour,minutes,seconds)
var d=new Date(temp[1],temp[3]-1,temp[5],temp[7],temp[9],temp[11]);
return d.getFullYear()==temp[1]&&
(d.getMonth()+1)==temp[3]&&
d.getDate()==temp[5]&&
d.getHours()==temp[7]&&
d.getMinutes()==temp[9]&&
d.getSeconds()==temp[11];
}
//只有年月 形如: 2003-12
function isDate(elem){
var pattern=/^([0-9]{4}|[0-9]{2})-([0-9]{1,2})$/;
var temp=elem.match(pattern);
if(temp==null) return false;
//Date(year,month)
var d=new Date(temp[1],temp[2]-1);
return d.getYear()==temp[1]&&(d.getMonth()+1)==temp[2];
}
//只有小时与分 形如: 04:47
//timePat=/^([1-9]|1[0-2]):[0-5]d$/;
function isTM(elem){
var pattern=/^(/d{1,2})(-|//|:)(/d{1,2})$/;
var temp=elem.match(pattern);
if(temp==null) return false;
var hour=parseInt(temp[1]);
var mint=parseInt(temp[3]);
if(hour>24) return false;
if(hour<0) return false;
if(mint>60) return false;
if(mint<0) return false;
return true;
}
//判断leapYear (格式2003-12-18) (没有测试)
function isLeapYear(elem){
//选用上面的函数检验elem的有效性
if(isShortDate(elem)==false){
//输入的时间不格式不正确
return false;
}
var temp=elem.split("-");
var year=parseInt(temp[0]);
if((year%100)==0){
return (year%400)==0;
}else{
return (year%4)==0;
}
}
// *******************************************************结束时间类*******************************************
//======================================浏览器类=============================
//浏览器版本检测
//获取浏览器的名字Netscape或者Microsoft Internet Explorer
var browserName=navigator.appName;
//获取浏览器的版本信息
var browserVersion=parseInt(navigator.appVersion);
var browser;
if(browserName=="Netscape"&&browserVersion==5){
browser="nn6"; //netspace6
}
else if(browserName="Netscape"&&browserVersion==4){
browser="nn4"; //netspace4
}
else if(browserName="Microsoft Internet Explorer"&&
browserVersion==4&&navigator.appVersion.indexOf("MSIE 6.0")!=-1){
browser="ie6"; //IE 6.0
}
else if(browserName="Microsoft Internet Explorer"&&
browserVersion==4&&
navigator.appVersion.indexOf("MSIE 5.5")!=-1){
browser="ie55"; //IE5.5
}
else if(browserName="Microsoft Internet Explorer"&&
browserVersion==4&&
navigator.appVersion.indexOf("MSIE 5.0")!=-1){
browser="ie5"; //IE5.0
}
else if(browserName="Microsoft Internet Explorer"&&
browserVersion==4){
browser="ie4"; //IE4
}
/*
if(browser=="nn6"||browser=="ie6"||browser=="ie55"||browser="ie5"){
//不与高版本要求的代码
}else if(browser=="ie4"){
//不兼容nn4的代码
}else if(browser=="nn4"){
//不兼容ie4的代码
}
*/
/* *********************************end browser **************************** */
//判断操作平台是不是win98
function isWin98(){
if(navigator.appVersion.indexOf("98")!=-1){
return true;
}else{
//alert("你使用不是windows98操作系统");
return false;
}
}
//分辨率的检测
function redirectPage(){
//分辨率初始化
var size;
if(screen.width==640&&screen.height==480)
return size="640 x 480";
if(screen.width==800&&screen.height==600)
return size="800 x 600";
if(screen.width==1024&&screen.height==768)
return size="1024 x 768";
else
return size="640 x 480";
}
// /结束浏览器类///
发一个将阿拉伯数字转换成中文大写的函数:
function Chinese(num) //将阿拉伯数字翻译成中文的大写数字
{
if(!/^/d*(/./d*)?$/.test(num)){alert("Number is wrong!"); return "Number is wrong!";}
var AA = new Array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖");
var BB = new Array("","拾","佰","仟","萬","億","点","");
var a = (""+ num).replace(/(^0*)/g, "").split("."), k = 0, re = "";
for(var i=a[0].length-1; i>=0; i--)
{
switch(k)
{
case 0 : re = BB[7] + re; break;
case 4 : if(!new RegExp("0{4}//d{"+ (a[0].length-i-1) +"}$").test(a[0]))
re = BB[4] + re; break;
case 8 : re = BB[5] + re; BB[7] = BB[5]; k = 0; break;
}
if(k%4 == 2 && a[0].charAt(i+2) != 0 && a[0].charAt(i+1) == 0) re = AA[0] + re;
if(a[0].charAt(i) != 0) re = AA[a[0].charAt(i)] + BB[k%4] + re; k++;
}
if(a.length>1) //加上小数部分(如果有小数部分)
{
re += BB[6];
for(var i=0; i<a[1].length; i++) re += AA[a[1].charAt(i)];
}
return re;
}
//=================================字符串类===============================
//禁止全角
function isQj(elem){
//[/u4E00-/u9FA5]汉字﹐[/uFE30-/uFFA0]全角字符
var pattern=/[/uFE30-/uFFA0]/gi;
if(pattern.test(elem)){
//不为汉字
//alert("不能用全角");
//elem="";
return false;
}else{
//输入正常
return true;
}
}
//含有非法字符~!@%^&*();'/"?><[]{}//|,:/=+—“”‘
function havegg(elem){
var str = "~!@%^&*();'/"?><[]{}//|,:/=+—“”‘";
for(i=0;i<elem.length;i++)
if (str.indexOf(elem.charAt(i)) !=-1){
return false;
}
return true;
}
//由a-z和A-Z组成的字符串
function isStr(elem){
var pattern=/^[a-zA-Z]+$/;
if(pattern.test(elem)){
return true;
}else{
return false;
}
}
//由字符串和数字字符串组成
function isStrAndInt(elem){
var patten=/^[a-zA-Z0-9]+$/;
if(pattern.test(elem)){
return true;
}else{
return false;
}
}
//判断字符由字母和数字,下划线,点号组成.且开头的只能是下划线和字母
function isStrin(elem){
var pattern=/^(/b[a-zA-Z]|/b_)([a-zA-Z0-9]+(_|/.)?[a-zA-Z0-9]*)+$/;
if(pattern.test(elem)){
return true;
}else{
return false;
}
}
// 字符串完毕/
//============================数字类=========================================
//邮政编码
//要求:无地区规律,但都是6位数字,最大值为(西藏拉萨850000),最小值为(呼和浩特010000)
function isPost(elem){
var pattern=/^[0-9]{6}$/;
if(!pattern.test(elem)){
return false;
}else{
if(parseInt(elem)<10000||parseInt(elem)>850000){
return false;
}
return true;
}
}
//整数(可以带正负符号或者不带符号表正数)
function isInt(elem){
var pattern=/^(/-|+)?/d+$/;
if(!pattern.test(elem)){
return false;
}else{
return true;
}
}
//负数
function isNegative(elem){
var pattern=/^/b/-d+$/;
if(!pattern.test(elem)){
return false;
}else{
return true;
}
}
//数字字符
function isFigStr(elem){
var pattern=/^/d+$/;
if(!pattern.test(elem)){
return false;
}else{
return true;
}
}
//不大于imax,不小于imix的整数
function isScopeInt(elem){
var imax=80000;
var imix=100;
//判断elem是否为整数,向上参考
if(isInt(elem)==false){
//alert("elem不是整数");
return false;
}
if(parseInt(elem)>imax){
return false;
}
if(parseInt(elem)<imix){
return false;
}
return true;
}
// //数据类结束
//验证IP地址
function isIP3(elem){
var pattern=/(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])/.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)/.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)/.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])/;
if(pattern.test(elem)){
return true;
}else{
//alert("ip格式不正确");
return false;
}
}
// /end IP
//移动电话(手机)
//样式:13531214732或013531214732
function isMoveTel(elem){
var pattern=/^0{0,1}13[0-9]{9}$/;
if(pattern.test(elem)){
return true;
}else{
//elert("电话号码不正确");
return false;
}
}
//固定电话(小灵通。。。。家庭电话)
function isFixTel(elem){
var pattern=/(^[0-9]{3,4}/-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^/([0-9]{3,4}/)[0-9]{3,8}$)/;
if(pattern.test(elem)){
return true;
}else{
//alert("电话号码格式不正确");
return false;
}
}
//电话号码(以上二种)
function isTel(elem){
var pattern=/(^[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}$)/;
if(pattern.test(elem)){
return true;
}else{
//elert("电话号码格式不正确");
return false;
}
}
自定以右键菜单。
<HTML><HEAD><TITLE>右键菜单的淡入淡出效果</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<SCRIPT language=JavaScript>
<!-- // RightClickMenu
var intDelay=10; //设置菜单显示速度,越大越慢
var intInterval=5; //每次更改的透明度
function showmenuie5(){
var rightedge=document.body.clientWidth-event.clientX
var bottomedge=document.body.clientHeight-event.clientY
if (rightedge<ie5menu.offsetWidth)
ie5menu.style.left=document.body.scrollLeft+event.clientX-ie5menu.offsetWidth
else
ie5menu.style.left=document.body.scrollLeft+event.clientX
if (bottomedge<ie5menu.offsetHeight)
ie5menu.style.top=document.body.scrollTop+event.clientY-ie5menu.offsetHeight
else
ie5menu.style.top=document.body.scrollTop+event.clientY
ie5menu.style.visibility="visible"
//ie5menu.style.visibility=""
ie5menu.filters.alpha.opacity=0
GradientShow()
return false
}
function hidemenuie5(){
//ie5menu.style.visibility="hidden"
GradientClose()
}
function highlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor="highlight"
event.srcElement.style.color="white"
}
}
function lowlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="#000000"
}
}
function jumptoie5(){
if (event.srcElement.className=="menuitems"){
if (event.srcElement.url != ''){
if (event.srcElement.getAttribute("target")!=null)
window.open(event.srcElement.url,event.srcElement.getAttribute("target"))
else
window.location=event.srcElement.url
}
}
}
function GradientShow() //实现淡入的函数
{
ie5menu.filters.alpha.opacity+=intInterval
if (ie5menu.filters.alpha.opacity<100) setTimeout("GradientShow()",intDelay)
}
function GradientClose() //实现淡出的函数
{
ie5menu.filters.alpha.opacity-=intInterval
if (ie5menu.filters.alpha.opacity>0) {
setTimeout("GradientClose()",intDelay)
}
else {
ie5menu.style.visibility="hidden"
}
}
function ChangeBG() //改变菜单项的背景颜色,这里的两种颜色值可以改为你需要的
{
oEl=event.srcElement
if (oEl.style.background!="navy") {
oEl.style.background="navy"
}
else {
oEl.style.background="#cccccc"
}
}
// -->
</SCRIPT>
<STYLE type=text/css>
.cMenu {
FILTER: alpha(opacity=0);BACKGROUND-COLOR: #D6D3CE;BORDER-BOTTOM: #666666 2px solid; BORDER-LEFT: #E4E4E4 2px solid; BORDER-RIGHT: #666666 2px solid; BORDER-TOP: #E4E4E4 2px solid; COLOR: #000000; CURSOR: default; FONT-SIZE: 9pt; color:#000000;FONT-WEIGHT: normal; LINE-HEIGHT: 20px; POSITION: absolute; VISIBILITY: hidden; WIDTH: 110px
}
.menuitems {
font-size:9pt;
MARGIN: 2px;
PADDING-BOTTOM: 0px;
PADDING-LEFT: 15px;
PADDING-RIGHT: 3px;
PADDING-TOP: 0px;
}
</STYLE>
<META content="Microsoft FrontPage 4.0" name=GENERATOR>
</HEAD>
<BODY>
<OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 id=WebBrowser width=0>
</OBJECT>
<RIGHTCLICK><!--[if IE]>
<DIV class=cMenu id=ie5menu οnclick=jumptoie5() οnmοuseοut=lowlightie5()
οnmοuseοver=highlightie5()>
<DIV class=menuitems url="javascript:click_obj(0)">后退</DIV>
<DIV class=menuitems url="javascript:click_obj(1)">前进</DIV>
<DIV class=menuhr><hr style="width:100%"></DIV>
<DIV class=menuitems url="javascript:click_obj(2)">刷新</DIV>
<DIV class=menuitems url="javascript:click_obj(3)">加入收藏夹</DIV>
<DIV class=menuitems url="javascript:click_obj(4)">查看源文件</DIV>
<DIV class=menuhr><hr style="width:100%"></DIV>
<DIV class=menuitems url="javascript:click_obj(5)">属性</DIV>
</DIV>
<![endif]-->
<SCRIPT language=JavaScript>
<!--
function click_obj(id){
switch(id){
case 0:
history.back()
break
case 1:
history.forward()
break
case 2:
window.location.reload()
break
case 3:
window.external.AddFavorite(location.href, document.title)
break
case 4:
window.location = "view-source:" + window.location.href
break
case 5:
document.all.WebBrowser.ExecWB(10,1)
break
}
}
if (document.all&&window.print){
ie5menu.className="cMenu"
document.οncοntextmenu=showmenuie5
document.body.οnclick=hidemenuie5
}
//-->
</SCRIPT>
</RIGHTCLICK>
</BODY></HTML>
义省份和城市名。[全+转]
<head>
<style>
<!--
body { font-size: 14px }
-->
</style>
<form action="http://www.chinaleader.com/cgi-bin/register.cgi" method=post name="creator" enctype="multipart/form-data">
<script language="javascript">
<!--
var where = new Array(35);
function comefrom(loca,locacity) { this.loca = loca; this.locacity = locacity; }
where[0]= new comefrom("请选择省份名","请选择城市名");
where[1] = new comefrom("北京","|东城|西城|崇文|宣武|朝阳|丰台|石景山|海淀|门头沟|房山|通州|顺义|昌平|大兴|平谷|怀柔|密云|延庆");
where[2] = new comefrom("上海","|黄浦|卢湾|徐汇|长宁|静安|普陀|闸北|虹口|杨浦|闵行|宝山|嘉定|浦东|金山|松江|青浦|南汇|奉贤|崇明");
where[3] = new comefrom("天津","|和平|东丽|河东|西青|河西|津南|南开|北辰|河北|武清|红挢|塘沽|汉沽|大港|宁河|静海|宝坻|蓟县");
where[4] = new comefrom("重庆","|万州|涪陵|渝中|大渡口|江北|沙坪坝|九龙坡|南岸|北碚|万盛|双挢|渝北|巴南|黔江|长寿|綦江|潼南|铜梁|大足|荣昌|壁山|梁平|城口|丰都|垫江|武隆|忠县|开县|云阳|奉节|巫山|巫溪|石柱|秀山|酉阳|彭水|江津|合川|永川|南川");
where[5] = new comefrom("河北","|石家庄|邯郸|邢台|保定|张家口|承德|廊坊|唐山|秦皇岛|沧州|衡水");
where[6] = new comefrom("山西","|太原|大同|阳泉|长治|晋城|朔州|吕梁|忻州|晋中|临汾|运城");
where[7] = new comefrom("内蒙古","|呼和浩特|包头|乌海|赤峰|呼伦贝尔盟|阿拉善盟|哲里木盟|兴安盟|乌兰察布盟|锡林郭勒盟|巴彦淖尔盟|伊克昭盟");
where[8] = new comefrom("辽宁","|沈阳|大连|鞍山|抚顺|本溪|丹东|锦州|营口|阜新|辽阳|盘锦|铁岭|朝阳|葫芦岛");
where[9] = new comefrom("吉林","|长春|吉林|四平|辽源|通化|白山|松原|白城|延边");
where[10] = new comefrom("黑龙江","|哈尔滨|齐齐哈尔|牡丹江|佳木斯|大庆|绥化|鹤岗|鸡西|黑河|双鸭山|伊春|七台河|大兴安岭");
where[11] = new comefrom("江苏","|南京|镇江|苏州|南通|扬州|盐城|徐州|连云港|常州|无锡|宿迁|泰州|淮安");
where[12] = new comefrom("浙江","|杭州|宁波|温州|嘉兴|湖州|绍兴|金华|衢州|舟山|台州|丽水");
where[13] = new comefrom("安徽","|合肥|芜湖|蚌埠|马鞍山|淮北|铜陵|安庆|黄山|滁州|宿州|池州|淮南|巢湖|阜阳|六安|宣城|亳州");
where[14] = new comefrom("福建","|福州|厦门|莆田|三明|泉州|漳州|南平|龙岩|宁德");
where[15] = new comefrom("江西","|南昌市|景德镇|九江|鹰潭|萍乡|新馀|赣州|吉安|宜春|抚州|上饶");
where[16] = new comefrom("山东","|济南|青岛|淄博|枣庄|东营|烟台|潍坊|济宁|泰安|威海|日照|莱芜|临沂|德州|聊城|滨州|菏泽");
where[17] = new comefrom("河南","|郑州|开封|洛阳|平顶山|安阳|鹤壁|新乡|焦作|濮阳|许昌|漯河|三门峡|南阳|商丘|信阳|周口|驻马店|济源");
where[18] = new comefrom("湖北","|武汉|宜昌|荆州|襄樊|黄石|荆门|黄冈|十堰|恩施|潜江|天门|仙桃|随州|咸宁|孝感|鄂州");
where[19] = new comefrom("湖南","|长沙|常德|株洲|湘潭|衡阳|岳阳|邵阳|益阳|娄底|怀化|郴州|永州|湘西|张家界");
where[20] = new comefrom("广东","|广州|深圳|珠海|汕头|东莞|中山|佛山|韶关|江门|湛江|茂名|肇庆|惠州|梅州|汕尾|河源|阳江|清远|潮州|揭阳|云浮");
where[21] = new comefrom("广西","|南宁|柳州|桂林|梧州|北海|防城港|钦州|贵港|玉林|南宁地区|柳州地区|贺州|百色|河池");
where[22] = new comefrom("海南","|海口|三亚");
where[23] = new comefrom("四川","|成都|绵阳|德阳|自贡|攀枝花|广元|内江|乐山|南充|宜宾|广安|达川|雅安|眉山|甘孜|凉山|泸州");
where[24] = new comefrom("贵州","|贵阳|六盘水|遵义|安顺|铜仁|黔西南|毕节|黔东南|黔南");
where[25] = new comefrom("云南","|昆明|大理|曲靖|玉溪|昭通|楚雄|红河|文山|思茅|西双版纳|保山|德宏|丽江|怒江|迪庆|临沧");
where[26] = new comefrom("西藏","|拉萨|日喀则|山南|林芝|昌都|阿里|那曲");
where[27] = new comefrom("陕西","|西安|宝鸡|咸阳|铜川|渭南|延安|榆林|汉中|安康|商洛");
where[28] = new comefrom("甘肃","|兰州|嘉峪关|金昌|白银|天水|酒泉|张掖|武威|定西|陇南|平凉|庆阳|临夏|甘南");
where[29] = new comefrom("宁夏","|银川|石嘴山|吴忠|固原");
where[30] = new comefrom("青海","|西宁|海东|海南|海北|黄南|玉树|果洛|海西");
where[31] = new comefrom("新疆","|乌鲁木齐|石河子|克拉玛依|伊犁|巴音郭勒|昌吉|克孜勒苏柯尔克孜|博尔塔拉|吐鲁番|哈密|喀什|和田|阿克苏");
where[32] = new comefrom("香港","");
where[33] = new comefrom("澳门","");
where[34] = new comefrom("台湾","|台北|高雄|台中|台南|屏东|南投|云林|新竹|彰化|苗栗|嘉义|花莲|桃园|宜兰|基隆|台东|金门|马祖|澎湖");
where[35] = new comefrom("其它","|北美洲|南美洲|亚洲|非洲|欧洲|大洋洲");
function select() {
with(document.creator.province) { var loca2 = options[selectedIndex].value; }
for(i = 0;i < where.length;i ++) {
if (where[i].loca == loca2) {
loca3 = (where[i].locacity).split("|");
for(j = 0;j < loca3.length;j++) { with(document.creator.city) { length = loca3.length; options[j].text = loca3[j]; options[j].value = loca3[j]; var loca4=options[selectedIndex].value;}}
break;
}}
document.creator.newlocation.value=loca2+loca4;
}
function init() {
with(document.creator.province) {
length = where.length;
for(k=0;k<where.length;k++) { options[k].text = where[k].loca; options[k].value = where[k].loca; }
options[selectedIndex].text = where[0].loca; options[selectedIndex].value = where[0].loca;
}
with(document.creator.city) {
loca3 = (where[0].locacity).split("|");
length = loca3.length;
for(l=0;l<length;l++) { options[l].text = loca3[l]; options[l].value = loca3[l]; }
options[selectedIndex].text = loca3[0]; options[selectedIndex].value = loca3[0];
}}
-->
</script>
</head>
<body οnlοad="init()">
<font color=#000000><b>来自:</b><br>请输入您所在国家的具体地方。此项可选<br><br>
省份 <select name="province" onChange = "select()"></select> 城市 <select name="city" onChange = "select()"></select><br>
我在 <input type=text name="newlocation" maxlength=12 size=12 style="font-weight: bold"> 不能超过12个字符(6个汉字)
</form>
右键级联菜单
<script language="JScript">
<!--
function RightMenu()
{
this.AddExtendMenu=AddExtendMenu;
this.AddItem=AddItem;
this.GetMenu=GetMenu;
this.HideAll=HideAll;
this.I_OnMouseOver=I_OnMouseOver;
this.I_OnMouseOut=I_OnMouseOut;
this.I_OnMouseUp=I_OnMouseUp;
this.P_OnMouseOver=P_OnMouseOver;
this.P_OnMouseOut=P_OnMouseOut;
A_rbpm = new Array();
HTMLstr = "";
HTMLstr += "<!-- RightButton PopMenu -->/n";
HTMLstr += "/n";
HTMLstr += "<!-- PopMenu Starts -->/n";
HTMLstr += "<div id='E_rbpm' class='rm_div'>/n";
// rbpm = right button pop menu
HTMLstr += "<table width='100%' border='0' cellspacing='0'>/n";
HTMLstr += "<!-- Insert A Extend Menu or Item On Here For E_rbpm -->/n";
HTMLstr += "</table>/n";
HTMLstr += "</div>/n";
HTMLstr += "<!-- Insert A Extend_Menu Area on Here For E_rbpm -->";
HTMLstr += "/n";
HTMLstr += "<!-- PopMenu Ends -->/n";
}
function AddExtendMenu(id,name,parent)
{
var TempStr = "";
if(HTMLstr.indexOf("<!-- Extend Menu Area : E_"+id+" -->") != -1)
{
alert("E_"+id+"already exist!");
return;
}
eval("A_"+parent+".length++");
eval("A_"+parent+"[A_"+parent+".length-1] = id"); // 将此项注册到父菜单项的ID数组中去
TempStr += "<!-- Extend Menu Area : E_"+id+" -->/n";
TempStr += "<div id='E_"+id+"' class='rm_div'>/n";
TempStr += "<table width='100%' border='0' cellspacing='0'>/n";
TempStr += "<!-- Insert A Extend Menu or Item On Here For E_"+id+" -->";
TempStr += "</table>/n";
TempStr += "</div>/n";
TempStr += "<!-- Insert A Extend_Menu Area on Here For E_"+id+" -->";
TempStr += "<!-- Insert A Extend_Menu Area on Here For E_"+parent+" -->";
HTMLstr = HTMLstr.replace("<!-- Insert A Extend_Menu Area on Here For E_"+parent+" -->",TempStr);
eval("A_"+id+" = new Array()");
TempStr = "";
TempStr += "<!-- Extend Item : P_"+id+" -->/n";
TempStr += "<tr id='P_"+id+"' class='out'";
TempStr += " οnmοuseοver='P_OnMouseOver(/""+id+"/",/""+parent+"/")'";
TempStr += " οnmοuseοut='P_OnMouseOut(/""+id+"/",/""+parent+"/")'";
TempStr += " οnmοuseup=window.event.cancelBubble=true;";
TempStr += " οnclick=window.event.cancelBubble=true;";
TempStr += "><td nowrap>";
TempStr += " "+name+" </td><td style='font-family: webdings; text-align: right;'>4";
TempStr += "</td></tr>/n";
TempStr += "<!-- Insert A Extend Menu or Item On Here For E_"+parent+" -->";
HTMLstr = HTMLstr.replace("<!-- Insert A Extend Menu or Item On Here For E_"+parent+" -->",TempStr);
}
>
右键级联菜单2
function AddItem(id,name,parent,location)
{
var TempStr = "";
var ItemStr = "<!-- ITEM : I_"+id+" -->";
if(id == "sperator")
{
TempStr += ItemStr+"/n";
TempStr += "<tr style='height: 3;' class='out' οnclick='window.event.cancelBubble=true;' οnmοuseup='window.event.cancelBubble=true;'><td colspan='2'><hr class='sperator'></td></tr>";
TempStr += "<!-- Insert A Extend Menu or Item On Here For E_"+parent+" -->";
HTMLstr = HTMLstr.replace("<!-- Insert A Extend Menu or Item On Here For E_"+parent+" -->",TempStr);
return;
}
if(HTMLstr.indexOf(ItemStr) != -1)
{
alert("I_"+id+"already exist!");
return;
}
TempStr += ItemStr+"/n";
TempStr += "<tr id='I_"+id+"' class='out'";
TempStr += " οnmοuseοver='I_OnMouseOver(/""+id+"/",/""+parent+"/")'";
TempStr += " οnmοuseοut='I_OnMouseOut(/""+id+"/")'";
TempStr += " οnclick='window.event.cancelBubble=true;'";
if(location == null)
TempStr += " οnmοuseup='I_OnMouseUp(/""+id+"/",/""+parent+"/",null)'";
else
TempStr += " οnmοuseup='I_OnMouseUp(/""+id+"/",/""+parent+"/",/""+location+"/")'";
TempStr += "><td nowrap>";
TempStr += " "+name+" ";
TempStr += "</td><td></td></tr>/n";
TempStr += "<!-- Insert A Extend Menu or Item On Here For E_"+parent+" -->";
HTMLstr = HTMLstr.replace("<!-- Insert A Extend Menu or Item On Here For E_"+parent+" -->",TempStr);
}
function GetMenu()
{
return HTMLstr;
}
function I_OnMouseOver(id,parent)
{
var Item;
if(parent != "rbpm")
{
var ParentItem;
ParentItem = eval("P_"+parent);
ParentItem.className="over";
}
Item = eval("I_"+id);
Item.className="over";
HideAll(parent,1);
}
function I_OnMouseOut(id)
{
var Item;
Item = eval("I_"+id);
Item.className="out";
}
function I_OnMouseUp(id,parent,location)
{
var ParentMenu;
window.event.cancelBubble=true;
OnClick();
ParentMenu = eval("E_"+parent);
ParentMenu.display="none";
if(location == null)
eval("Do_"+id+"()");
else
window.open(location);
}
function P_OnMouseOver(id,parent)
{
var Item;
var Extend;
var Parent;
if(parent != "rbpm")
{
var ParentItem;
ParentItem = eval("P_"+parent);
ParentItem.className="over";
}
HideAll(parent,1);
Item = eval("P_"+id);
Extend = eval("E_"+id);
Parent = eval("E_"+parent);
Item.className="over";
Extend.style.display="block";
Extend.style.posLeft=document.body.scrollLeft+Parent.offsetLeft+Parent.offsetWidth-4;
if(Extend.style.posLeft+Extend.offsetWidth > document.body.scrollLeft+document.body.clientWidth)
Extend.style.posLeft=Extend.style.posLeft-Parent.offsetWidth-Extend.offsetWidth+8;
if(Extend.style.posLeft < 0) Extend.style.posLeft=document.body.scrollLeft+Parent.offsetLeft+Parent.offsetWidth;
Extend.style.posTop=Parent.offsetTop+Item.offsetTop;
if(Extend.style.posTop+Extend.offsetHeight > document.body.scrollTop+document.body.clientHeight)
Extend.style.posTop=document.body.scrollTop+document.body.clientHeight-Extend.offsetHeight;
if(Extend.style.posTop < 0) Extend.style.posTop=0;
}
function P_OnMouseOut(id,parent)
{
}
function HideAll(id,flag)
{
var Area;
var Temp;
var i;
if(!flag)
{
Temp = eval("E_"+id);
Temp.style.display="none";
}
Area = eval("A_"+id);
if(Area.length)
{
for(i=0; i < Area.length; i++)
{
HideAll(Area[i],0);
Temp = eval("E_"+Area[i]);
Temp.style.display="none";
Temp = eval("P_"+Area[i]);
Temp.className="out";
}
}
}
document.οnmοuseup=OnMouseUp;
document.οnclick=OnClick;
function OnMouseUp()
{
if(window.event.button == 2)
{
var PopMenu;
PopMenu = eval("E_rbpm");
HideAll("rbpm",0);
PopMenu.style.display="block";
PopMenu.style.posLeft=document.body.scrollLeft+window.event.clientX;
PopMenu.style.posTop=document.body.scrollTop+window.event.clientY;
if(PopMenu.style.posLeft+PopMenu.offsetWidth > document.body.scrollLeft+document.body.clientWidth)
PopMenu.style.posLeft=document.body.scrollLeft+document.body.clientWidth-PopMenu.offsetWidth;
if(PopMenu.style.posLeft < 0) PopMenu.style.posLeft=0;
if(PopMenu.style.posTop+PopMenu.offsetHeight > document.body.scrollTop+document.body.clientHeight)
PopMenu.style.posTop=document.body.scrollTop+document.body.clientHeight-PopMenu.offsetHeight;
if(PopMenu.style.posTop < 0) PopMenu.style.posTop=0;
}
}
function OnClick()
{
HideAll("rbpm",0);
}
// Add Your Function on following
function Do_viewcode(){window.location="view-source:"+window.location.href;}
function Do_help(){window.showHelp(window.location);}
function Do_exit() {window.close();}
function Do_refresh() {window.location.reload();}
function Do_back() {history.back();}
function Do_forward() {history.forward();}
function Do_author(){alert("姓名:杨俊/n网名:风舞影天(Snwcwt)/nE_mail:snwcwt.com@263.net/n个人主页:http://202.115.147.160/snwcwt(正在制作中)/n")}
-->
</script>
右键级联菜单3(同一ID不能回复三次,只好用马甲了^_^)
<HTML>
<HEAD>
<TITLE>右键菜单</TITLE>
<style type="text/css">
<!--
body {font-size: 9pt;}
table {font-size: 9pt; cursor: default; margin: 0;}
tr {height: 20;}
tr.over {font-size: 9pt; color: #ffffff; background-color: #66aadd; cursor: default;}
tr.out {font-size: 9pt; color: #ffffff; background-color: #336699; cursor: default;}
div.rm_div {position: absolute; filter: Alpha(Opacity='95'); display: none; border: 2px outset #3377aa; background-color: #336699; width: 0; height: 0;}
hr.sperator {border: 1px inset #3377aa;}
-->
</style>
<script language="JScript">
//************************************************
//此处插入以上代码
//************************************************
</script>
</HEAD>
<BODY οncοntextmenu=window.event.returnValue=false>
<div id='snwcwt'> </div>
<script language="JScript">
<!--
var menu = new RightMenu();
menu.AddExtendMenu("location","我的链接","rbpm");
menu.AddExtendMenu("lscit","四川工业学院校园网","location");
menu.AddItem("scit_scit","川工首页","lscit","http://www.scit.edu.cn");
menu.AddItem("scit_lib","川工图书馆","lscit","http://202.115.151.46");
menu.AddItem("sperator","","lscit",null);
menu.AddItem("scit_century","世纪学苑","lscit","http://202.115.148.230/");
menu.AddItem("scit_the5","第五空间","lscit","http://the5.scit.edu.cn/");
menu.AddItem("scit_lianyi","联谊网站","lscit","http://202.115.148.240");
menu.AddItem("scit_message","信息导报","lscit","http://202.115.151.114/xx");
menu.AddItem("scit_student","书生之家川工境象","lscit","http://202.115.151.100");
menu.AddItem("sperator","","lscit",null);
menu.AddItem("scit_bbs","川工BBS","lscit","http://202.115.144.32");
menu.AddItem("scit_cbbs","世纪学苑BBS","lscit","http://202.115.144.37");
menu.AddExtendMenu("stunet","学生网站","location");
menu.AddItem("stu_century","世纪学苑","stunet","http://202.115.148.230/");
menu.AddItem("stu_wjl","望江楼","stunet","http://wjl.scu.edu.cn");
menu.AddItem("stu_freedim","自由天地","stunet","http://www.freedim.net/");
menu.AddItem("stu_stuhome","学生之家","stunet","http://www.stuhome.net");
menu.AddItem("stu_rw","人文网","stunet","http://www.rw.uestc.edu.cn/");
menu.AddItem("stu_the5","第五空间","stunet","http://the5.scit.edu.cn/");
menu.AddItem("stu_flying","我心飞扬","stunet","http://flying.swpi.edu.cn/");
menu.AddItem("stu_21cn","21CN校园网","stunet","http://www.21cn.edu.cn/");
menu.AddItem("stu_yaguo","网虫乐园","stunet","http://www.yaguo.com/");
menu.AddItem("sperator","","location",null);
menu.AddExtendMenu("computer","电脑类网站","location");
menu.AddExtendMenu("C_all","综合性网站","computer");
menu.AddItem("ca_yesky","天极网","C_all","http://www.yesky.com");
menu.AddExtendMenu("C_program","程序员网站","computer");
menu.AddItem("cp_program","中国程序员网站","C_program","http://www.chinaprogrammer.com/");
menu.AddItem("sperator","","C_program",null);
menu.AddItem("cp_51js","无忧脚本","C_program","http://www.51js.com/");
menu.AddItem("sperator","","C_program",null);
menu.AddItem("cp_active","中国动感技术网络","C_program","http://www.chinaasp.com/active/");
menu.AddItem("cp_aspcn","ASP中华网","C_program","http://www.aspcn.com/");
menu.AddItem("cp_aspx","中国ASP联盟","C_program","http://www.chinaspx.com/");
menu.AddExtendMenu("C_magzine","杂志网站","computer");
menu.AddItem("cm_cpcw","电脑报","C_magzine","http://www.cpcw.com");
menu.AddItem("cm_cfan","电脑爱好者","C_magzine","http://www.cfan.net.cn");
menu.AddItem("cm_popsoft","大众软件","C_magzine","http://www.popsoft.com");
menu.AddExtendMenu("C_luntan","技术性论坛","computer");
menu.AddItem("cl_chinaasp","ChinaASP论坛","C_luntan","http://www.chinaasp.com/sqlbbs");
menu.AddExtendMenu("C_book","书籍下载","computer");
menu.AddItem("cb_huachu","华储网上书店","C_book","http://www.huachu.com.cn/");
menu.AddExtendMenu("hacker","黑客天地","location");
menu.AddItem("hk_honker","<font style='color: #ff0000;'>中国红客联盟</font>","hacker","http://www.cnhonker.com");
menu.AddItem("sperator","","location",null);
menu.AddExtendMenu("lmovie","影视天地","location");
menu.AddItem("mov_wcums","华西网上影院","lmovie","http://202.115.100.8/");
menu.AddExtendMenu("lmusic","音乐空间","location");
menu.AddItem("mus_tyfo","天虎音乐网","lmusic","http://music.tyfo.com/");
menu.AddItem("mus_langqin","浪琴音乐","lmusic","http://www.langqin.net/");
menu.AddItem("mus_wcums","华西音乐空间","lmusic","http://music.wcums.edu.cn/");
menu.AddExtendMenu("lmud","泥巴链接","location");
menu.AddItem("lmud_mudking","泥巴大王","lmud","http://www.mudking.com");
menu.AddItem("lmud_justmud","泥巴城堡","lmud","http://www.justmud.com");
menu.AddItem("lmud_mudall","世界泥巴资源","lmud","http://www.mudall.com");
menu.AddItem("lmud_yaguo","泥潭风云","lmud","http://202.114.98.14/mud/");
menu.AddItem("sperator","","location",null);
menu.AddExtendMenu("lemail","电子邮局","location");
menu.AddItem("email_263","263免费电子邮局","lemail","http://freemail.263.net");
menu.AddExtendMenu("collections","综合性网站","location");
menu.AddItem("coll_chinaren","中国人网站","collections","http://www.chinaren.com/");
menu.AddItem("coll_etang","亿唐网站","collections","http://www.etang.com/");
menu.AddItem("coll_263","263首都在线","collections","http://www.263.net/");
menu.AddExtendMenu("leave","离开","rbpm");
menu.AddItem("forward","前进","leave",null);
menu.AddItem("back","后退","leave",null);
menu.AddItem("sperator","","leave",null);
menu.AddItem("exit","退出","leave",null);
menu.AddItem("viewcode","查看源代码","rbpm",null);
menu.AddItem("refresh","刷新","rbpm",null);
menu.AddItem("sperator","","rbpm",null);
menu.AddItem("help","帮助","rbpm",null);
menu.AddItem("sperator","","rbpm",null);
menu.AddItem("author","<font style='color: #ff0000'>关于作者</font>","rbpm",null);
document.writeln(menu.GetMenu());
snwcwt.innerText=menu.GetMenu();
-->
</script>
</BODY>
</HTML>
【1、最基本的弹出窗口代码】
其实代码非常简单:
<SCRIPT LANGUAGE="javascript">
<!--
window.open ('page.html')
-->
</SCRIPT>
因为这是一段javascripts代码,所以它们应该放在<SCRIPT LANGUAGE="javascript">之间。<!-- 和 -->是对一些版本低的浏览器起作用,在这些老浏览器中不会将标签中的代码作为文本显示出来。要养成这个好习惯啊。
window.open ('page.html') 用于控制弹出新的窗口page.html,如果page.html不与主窗口在同一路径下,前面应写明路径,绝对路径(http://)和相对路径(../)均可。
用单引号和双引号都可以,只是不要混用。
这一段代码可以加入HTML的任意位置,<head>和</head>之间可以,<body>间</body>也可以,越前越早执行,尤其是页面代码长,又想使页面早点弹出就尽量往前放。也可以,越前越早执行,尤其是页面代码长,又想使页面早点弹出就尽量往前放。
【2、经过设置后的弹出窗口】
下面再说一说弹出窗口的设置。只要再往上面的代码中加一点东西就可以了。我们来定制这个弹出的窗口的外观,尺寸大小,弹出的位置以适应该页面的具体情况。
<SCRIPT LANGUAGE="javascript">
<!--
window.open ('page.html', 'newwindow', 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no,status=no')
//写成一行
-->
</SCRIPT>
参数解释:
<SCRIPT LANGUAGE="javascript"> js脚本开始;
window.open 弹出新窗口的命令;
'page.html' 弹出窗口的文件名;
'newwindow' 弹出窗口的名字(不是文件名),非必须,可用空''代替;
height=100 窗口高度;
width=400 窗口宽度;
top=0 窗口距离屏幕上方的象素值;
left=0 窗口距离屏幕左侧的象素值;
toolbar=no 是否显示工具栏,yes为显示;
menubar,scrollbars 表示菜单栏和滚动栏。
resizable=no 是否允许改变窗口大小,yes为允许;
location=no 是否显示地址栏,yes为允许;
status=no 是否显示状态栏内的信息(通常是文件已经打开),yes为允许;
</SCRIPT> js脚本结束
【3、用函数控制弹出窗口】
下面是一个完整的代码:
<html>
<head>
<script LANGUAGE="JavaScript">
<!--
function openwin() {
window.open ("page.html", "newwindow", "height=100, width=400, toolbar=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no")
//写成一行
}
//-->
</script>
</head>
<body οnlοad="openwin()">
...任意的页面内容...
</body>
</html>
这里定义了一个函数openwin(),函数内容就是打开一个窗口。在调用它之前没有任何用途。
怎么调用呢?
方法一:<body οnlοad="openwin()"> 浏览器读页面时弹出窗口;
方法二:<body οnunlοad="openwin()"> 浏览器离开页面时弹出窗口;
方法三:用一个连接调用:<a href="#" οnclick="openwin()">打开一个窗口</a>
注意:使用的“#”是虚连接。
方法四:用一个按钮调用:<input type="button" οnclick="openwin()" value="打开窗口">
【4、同时弹出2个窗口】
对源代码稍微改动一下:
<script LANGUAGE="JavaScript">
<!--
function openwin() {
window.open ("page.html", "newwindow", "height=100, width=100, top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no,status=no")
//写成一行
window.open ("page2.html", "newwindow2", "height=100, width=100, top=100,left=100,toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no,status=no")
//写成一行
}
//-->
</script>
为避免弹出的2个窗口覆盖,用top和left控制一下弹出的位置不要相互覆盖即可。最后用上面说过的四种方法调用即可。
注意:2个窗口的name(newwindows和newwindow2)不要相同,或者干脆全部为空。OK?
【5、主窗口打开文件1.htm,同时弹出小窗口page.html】
如下代码加入主窗口<head>区:
<script language="javascript">
<!--
function openwin() {
window.open("page.html","","width=200,height=200")
}
//-->
</script>
加入<body>区:
<a href="1.htm" οnclick="openwin()">open</a>即可。
【6、弹出的窗口之定时关闭控制】
下面我们再对弹出的窗口进行一些控制,效果就更好了。如果我们再将一小段代码加入弹出的页面(注意是加入到page.html的HTML中,可不是主页面中,否则...),让它10秒后自动关闭是不是更酷了?
首先,将如下代码加入page.html文件的<head>区:
<script language="JavaScript">
function closeit() {
setTimeout("self.close()",10000) //毫秒
}
</script>
然后,再用<body οnlοad="closeit()"> 这一句话代替page.html中原有的<BODY>这一句就可以了。(这一句话千万不要忘记写啊!这一句的作用是调用关闭窗口的代码,10秒钟后就自行关闭该窗口。)
【7、在弹出窗口中加上一个关闭按钮】
<FORM>
<INPUT TYPE='BUTTON' VALUE='关闭' onClick='window.close()'>
</FORM>
呵呵,现在更加完美了!
【8、内包含的弹出窗口---一个页面两个窗口】
上面的例子都包含两个窗口,一个是主窗口,另一个是弹出的小窗口。通过下面的例子,你可以在一个页面内完成上面的效果。
<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
function openwin()
{
OpenWindow=window.open("", "newwin", "height=250, width=250,toolbar=no,scrollbars="+scroll+",menubar=no");
//写成一行
OpenWindow.document.write("<TITLE>例子</TITLE>")
OpenWindow.document.write("<BODY BGCOLOR=#ffffff>")
OpenWindow.document.write("<h1>Hello!</h1>")
OpenWindow.document.write("New window opened!")
OpenWindow.document.write("</BODY>")
OpenWindow.document.write("</HTML>")
OpenWindow.document.close()
}
</SCRIPT>
</head>
<body>
<a href="#" οnclick="openwin()">打开一个窗口</a>
<input type="button" οnclick="openwin()" value="打开窗口">
</body>
</html>
看看OpenWindow.document.write()里面的代码不就是标准的HTML吗?只要按照格式写更多的行即可。千万注意多一个标签或少一个标签就会出现错误。记得用OpenWindow.document.close()结束啊。
【9、终极应用--弹出的窗口之Cookie控制】
回想一下,上面的弹出窗口虽然酷,但是有一点小毛病(沉浸在喜悦之中,一定没有发现吧?)比如你将上面的脚本放在一个需要频繁经过的页面里(例如首页),那么每次刷新这个页面,窗口都会弹出一次,是不是非常烦人?:-(
有解决的办法吗?当然有!我们使用cookie来控制一下就可以了。首先,将如下代码加入主页面HTML的<HEAD>区:
<script>
function openwin(){
window.open("page.html","","width=200,height=200")
}
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function loadpopup(){
if (get_cookie('popped')==''){
openwin()
document.cookie="popped=yes"
}
}
</script>
然后,用<body οnlοad="loadpopup()">(注意不是openwin而是loadpop啊!)替换主页面中原有的<BODY>这一句即可。你可以试着刷新一下这个页面或重新进入该页面,窗口再也不会弹出了。真正的Pop-Only-Once!
还有这个,用来保存用户习惯设置的
<STYLE>
.userData {BEHAVIOR: url(#default#userdata)}
</STYLE>
function savebehavior()
var oPersist=oPersistValue;
oPersist.setAttribute("sPersistText",0);
oPersist.save("oNoteWindowCount");
oPersist.load("oFolderBehavior");
if (oPersist.getAttribute("sPersistText")!=null)
{
oPersist.value=oPersist.getAttribute("sPersistText");
aFolderState=decodeBuddyIndexList(oPersistValue.value);
}//end
}
<div ID="oPersistValue" CLASS="userData" value=0 style="display:none"></div>
可以输入的SELECT
inputAndDrop.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns:inputAndDrop>
<HTML>
<HEAD>
<TITLE>Drop Down Menu</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=GB2312">
<LINK REL="stylesheet" HREF="./dropdownMenu.css" TYPE="text/css">
<style>
@media all {
inputAndDrop/:inputAndDrop {behavior:url(inputAndDrop.htc)}
}
</style>
</HEAD>
<BODY>
<select name=country style="display:none;">
<option value="AL">阿尔巴尼亚<option value="DZ">阿尔及利亚<option value="AF">阿富汗<option value="AR">阿根廷<option value="AE">阿拉伯联合酋长国<option value="AW">阿鲁巴<option value="OM">阿曼<option value="AZ">阿塞拜疆<option value="EG">埃及<option value="ET">埃塞俄比亚<option value="IE">爱尔兰<option value="EE">爱沙尼亚<option value="AD">安道尔<option value="AO">安哥拉<option value="AI">安圭拉岛<option value="AG">安提瓜和巴布达<option value="AT">奥地利<option value="AU">澳大利亚<option value="MO">澳门特别行政区<option value="BB">巴巴多斯<option value="PG">巴布亚新几内亚<option value="BS">巴哈马<option value="PK">巴基斯坦<option value="PY">巴拉圭<option value="BH">巴林<option value="PA">巴拿马<option value="BR">巴西<option value="BY">白俄罗斯<option value="BM">百慕大群岛<option value="BG">保加利亚<option value="MP">北马里亚纳群岛<option value="BJ">贝宁<option value="BE">比利时<option value="IS">冰岛<option value="PR">波多黎各<option value="PL">波兰<option value="BA">波斯尼亚和黑塞哥维那<option value="BO">玻利维亚<option value="BZ">伯利兹<option value="BW">博茨瓦纳<option value="BT">不丹<option value="IO">不列颠印度洋属土<option value="BF">布基纳法索<option value="BI">布隆迪<option value="BV">布韦岛<option value="KP">朝鲜<option value="GQ">赤道几内亚<option value="DK">丹麦<option value="DE">德国<option value="TP">东帝汶<option value="TG">多哥<option value="DM">多米尼克<option value="DO">多米尼克共和国<option value="RU">俄罗斯<option value="EC">厄瓜多尔<option value="ER">厄立特里亚<option value="FR">法国<option value="TF">法国南部和南极州<option value="FO">法罗群岛<option value="PF">法属波利尼西亚<option value="GF">法属圭亚那<option value="VA">梵蒂冈<option value="PH">菲律宾<option value="FJ">斐济群岛<option value="FI">芬兰<option value="CV">佛得角群岛<option value="FK">福克兰群岛(马尔维纳斯群岛)<option value="GM">冈比亚<option value="CG">刚果<option value="CD">刚果民主共和国<option value="CO">哥伦比亚<option value="CR">哥斯达黎加<option value="GD">格林纳达<option value="GL">格陵兰<option value="GE">格鲁吉亚<opvalue="GP">瓜德罗普岛(法属)<option value="GU">关岛<option value="GY">圭亚那<option value="KZ">哈萨克斯坦<option value="HT">海地<option value="KR">韩国<option value="NL">荷兰<option value="AN">荷属安的列斯群岛<option value="HM">赫德和麦克唐纳群岛<option value="HN">洪都拉斯<option value="KI">基里巴斯<option value="DJ">吉布提<option value="KG">吉尔吉斯斯坦<option value="GN">几内亚<option value="GW">几内亚比绍<option value="CA">加拿大<option value="GH">加纳<option value="GA">加蓬<option value="KH">柬埔寨<option value="CZ">捷克共和国<option value="ZW">津巴布韦<option value="CM">喀麦隆<option value="QA">卡塔尔<option value="KY">开曼群岛<option value="CC">科科斯群岛<option value="KM">科摩罗<option value="CI">科特迪瓦<option value="KW">科威特<option value="HR">克罗地亚(赫尔瓦次卡)<option value="KE">肯尼亚<option value="CK">库克群岛<option value="LV">拉脱维亚<option value="LS">莱索托<option value="LA">老挝<option value="LB">黎巴嫩<option value="LT">立陶宛<option value="LR">利比里亚<option value="LY">利比亚<option value="LI">列支敦士登<option value="RE">留尼汪岛<option value="LU">卢森堡<option value="RW">卢旺达<option value="RO">罗马尼亚<option value="MG">马达加斯加岛<option value="MV">马尔代夫<option value="MT">马耳他<option value="MW">马拉维<option value="MY">马来西亚<option value="ML">马里<option value="MK">马其顿共和国<option value="MH">马绍尔群岛<option value="MQ">马提尼克岛<option value="YT">马约特岛<option value="MU">毛里求斯<option value="MR">毛里塔尼亚<option value="US">美国<option value="AS">美属萨摩亚<option value="VI">美属维尔京群岛<option value="UM">美属小奥特兰群岛<option value="MN">蒙古<option value="MS">蒙特塞拉特(英)<option value="BD">孟加拉国<option value="PE">秘鲁<option value="FM">密克罗尼西亚<option value="MM">缅甸<option value="MD">摩尔多瓦<option value="MA">摩洛哥<option value="MC">摩纳哥<option value="MZ">莫桑比克<option value="MX">墨西哥<option value="NA">纳米比亚<option value="ZA">南非<option value="AQ">南极洲<option value="GS">南乔治亚和南桑<option value="NR">瑙鲁<option value="NP">尼泊尔<option value="NI">尼加拉瓜<option value="NE">尼日尔<option value="NG">尼日利亚<option value="NU">纽埃<option value="NO">挪威<option value="NF">诺福克岛<option value="PW">帕劳<option value="PN">皮特克恩群岛<option value="PT">葡萄牙<option value="JP">日本<option value="SE">瑞典<option value="CH">瑞士<option value="SV">萨尔瓦多<option value="WS">萨摩亚<option value="SL">塞拉利昂<option value="SN">塞内加尔<option value="CY">塞浦路斯<option value="SC">塞舌尔群岛<option value="SA">沙特阿拉伯<option value="CX">圣诞岛<option value="ST">圣多美和普林西比<option value="SH">圣赫勒拿岛<option value="KN">圣基茨和尼维斯<option value="LC">圣卢西亚<option value="SM">圣马力诺<option value="PM">圣皮埃尔岛和密克隆岛<option value="VC">圣文森特和格林纳丁斯<option value="LK">斯里兰卡<option value="SK">斯洛伐克<option value="SI">斯洛文尼亚<option value="SJ">斯瓦尔巴群岛和扬马延<option value="SZ">斯威士兰<option value="SD">苏丹<option value="SR">苏里南<option value="SB">所罗门群岛<option value="SO">索马里<option value="TJ">塔吉克斯坦<option value="TH">泰国<option value="TZ">坦桑尼亚<option value="TO">汤加<option value="TC">特克斯群岛和凯科斯群岛<option value="TT">特立尼达和多巴哥<option value="TN">突尼斯<option value="TV">图瓦卢<option value="TR">土耳其<option value="TM">土库曼斯坦<option value="TK">托克劳<option value="WF">瓦利斯群岛和富图纳群岛<option value="VU">瓦努阿图<option value="GT">危地马拉<option value="VE">委内瑞拉<option value="BN">文莱<option value="UG">乌干达<option value="UA">乌克兰<option value="UY">乌拉圭<option value="UZ">乌兹别克斯坦<option value="ES">西班牙<option value="GR">希腊<option value="HK">香港特别行政区<option value="SG">新加坡<option value="NC">新喀里多尼亚<option value="NZ">新西兰<option value="HU">匈牙利<option value="SY">叙利亚<option value="JM">牙买加<option value="AM">亚美尼亚<option value="YE">也门<option value="IQ">伊拉克<option value="IR">伊朗<option value="IL">以色列<option value="IT">意大利<option value="IN">印度<option value="ID">印度尼西亚<option value="UK">英国<option value="VG">英属维尔京群岛<option value="JO">约旦<option value="VN">越南<option value="ZM">赞比亚<option value="TD">乍得<option value="GI">直布罗陀<option value="CL">智利<option value="CF">中非共和国<option value="CN"selected>中国<option value="TW">中国台湾</select>
<inputAndDrop:inputAndDrop>
<input dataSrc="country">
<input>
<img src="inputAndDrop.jpg">
<select size=11 style="display:none"></select>
</inputAndDrop:inputAndDrop>
</BODY>
</HTML>
<SCRIPT LANGUAGE=javascript>
<!--
//-->
</SCRIPT>
可以输入的SELECT (2)
inputAndDrop.htc
<PUBLIC:ATTACH EVENT="onclick" ONEVENT="clickSwitcher()"/>
<PUBLIC:ATTACH EVENT="onkeyup" ONEVENT="keyupSwitcher()"/>
<PUBLIC:ATTACH EVENT="onload" ONEVENT="displayListForInputAndDrop()" FOR="window"/>
<PUBLIC:ATTACH EVENT="onclick" ONEVENT="windowClick()" FOR="document"/>
<SCRIPT LANGUAGE="JavaScript">
function displayListForInputAndDrop(){
children(3).style.position = "absolute";
children(3).style.display = "none";
children(3).style.left = children(0).offsetLeft;
children(3).style.top = children(0).offsetTop + children(0).offsetHeight - 2;
children(3).style.width = children(0).offsetWidth + 17;
children(2).style.position = "absolute";
children(2).style.left = children(0).offsetLeft + children(0).offsetWidth - 1;
children(2).style.top = children(0).offsetTop;
children(2).style.height = children(0).offsetHeight;
children(2).style.width = 17;
}
function judgeEventSrc(){
for (var i=0;i<children.length;i++){
if (children(i)==event.srcElement){
return (i);
}
}
}
function keyupSwitcher(){
switch(judgeEventSrc()){
case 0:
inputKeyup();
break;
case 1:
break;
case 2:
break;
case 3:
listKeyup();
break;
}
}
function clickSwitcher(){
switch(judgeEventSrc()){
case 0:
break;
case 1:
break;
case 2:
picClick();
break;
case 3:
listClick();
break;
}
}
function inputKeyup(){
if (children(0).value!=""){
if ((event.keyCode>=65 && event.keyCode<=90) || (event.keyCode>=96 && event.keyCode<=105) || (event.keyCode>=48 && event.keyCode<=57) || (event.keyCode==32) || (event.keyCode==46) || (event.keyCode==8)){
children(3).innerHTML = "";
var src = eval(children(0).dataSrc);
for (var i=0;i<src.length;i++){
var temp = document.createElement("option");
temp.value = src(i).value;
temp.text = src(i).text;
if (src(i).text.indexOf(children(0).value)==0){
children(3).add(temp);
}
}
if (children(3).length==0){
displayList("none");
}else{
if (children(3).length==1){
children(3).options(0).selected = true;
makeChoose();
displayList("none");
}else{
displayList("");
}
}
}
}else{
children(0).value = "";
children(1).value = "";
displayList("none");
}
}
function listKeyup(){
if (event.keyCode==38 || event.keyCode==40){
makeChoose();
}
if (event.keyCode==13){
displayList("none");
}
}
function picClick(){
if (children(3).style.display=="none"){
children(3).innerHTML = "";
var src = eval(children(0).dataSrc);
for (var i=0;i<src.length;i++){
var temp = document.createElement("option");
temp.value = src(i).value;
temp.text = src(i).text;
children(3).add(temp);
if (src(i).value==children(1).value){
children(3).options(i).selected=true;
}
}
displayList("");
children(3).focus();
}else{
displayList("none");
}
}
function listClick(){
makeChoose();
displayList("none");
}
function makeChoose(){
children(0).value = children(3).options(children(3).selectedIndex).text;
children(1).value = children(3).options(children(3).selectedIndex).value;
}
function displayList(tag){
if (children(3).length>0){
if (children(3).length<10){
children(3).size = children(3).length;
}else{
children(3).size = 10;
}
children(3).style.display=tag;
}else{
children(0).value = "";
children(1).value = "";
children(3).style.display="none";
}
}
function windowClick(){
if ((event.srcElement.parentElement!=element && event.srcElement!=element)){
// children(0).value = "";
// children(1).value = "";
displayList("none");
}
}
</SCRIPT>
table里的内容超长,自动切除并+ “...”
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<table width="100%" border="1" cellspacing="2" cellpadding="2">
<tr>
<td width="10%">s</td>
<td><div STYLE="width:200px; overflow:hidden;text-overflow:ellipsis"> <nobr> asdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdata goes here </nobr></div></td>
<td width="30%"> </td>
</tr>
<tr>
<td>d</td>
<td><div STYLE="width:200px; overflow:hidden;text-overflow:ellipsis"> <nobr> asdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdata goes here </nobr></div></td>
<td> </td>
</tr>
</table>
</body>
</html>
加入style="table-layout:fixed"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<table width="100%" border="1" cellspacing="2" cellpadding="2" style="table-layout:fixed">
<tr>
<td width="10%">s</td>
<td><div STYLE="width:100%; overflow:hidden;text-overflow:ellipsis"> <nobr> asdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdata goes here </nobr></div></td>
<td width="30%"> </td>
</tr>
<tr>
<td>d</td>
<td><div STYLE="width:100%; overflow:hidden;text-overflow:ellipsis"> <nobr> asdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdata goes here </nobr></div></td>
<td> </td>
</tr>
</table>
</body>
</html>