function exchangeImg(elm,pic1,pic2){ if(elm.src == R […]
字符串操作大全
function trim(str){ if(str==null) return “” […]
显示或者隐藏大全
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
//显示隐藏div,该函数应用于checkbox与div动态关联 //用户选中checkbox后div显示,取消选中时div隐藏 //输入参数:checkbox表单元素,div元素 function linkdisplay(checkbox, divID) { if (checkbox.checked) { divID.style.display = "block"; } else divID.style.display = "none"; } //显示/隐藏div元素 //输入参数:div元素 function display(selobj) { if (selobj.length == null) selobj.style.display = "block"; else for (var i = 0; i < selobj.length; i++) selobj[i].style.display = "block"; } function hidden(selobj) { if (selobj.length == null) selobj.style.display = "none"; else for (var i = 0; i < selobj.length; i++) selobj[i].style.display = "none"; } |
自由编辑表格
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
<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 = '确定'onclick = '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" onclick="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> |
回车键换为tab
在每个文本框的onblur事件中调用校验代码,并且每个文本框中onKeyDown事件中写一个enter转tab […]
只限制输入数字
具有在输入非数字字符不回显的效果,即对非数字字符的输入不作反应。 [code] function number […]
电话号码的验证
电话号码的验证 要求: (1)电话号码由数字、”(“、”)”和 […]
无边框窗口
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
<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(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; 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 onclick = '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' 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) != "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> |
验证IP地址格式是否正确
[html] ?<script LANGUAGE=”JavaScript”> […]
TABLAE相关(客户端动态增加行列)
[html] <html> <script LANGUAGE=”JScript& […]
写注册表
[code] <script> var WshShell = WScript.CreateObje […]
Javascript写注册表
1 2 3 4 5 6 7 8 9 10 |
<script> var WshShell = WScript.CreateObject("WScript.Shell"); WshShell.RegWrite ("HKCUSoftwareACMEFortuneTeller", 1, "REG_BINARY"); WshShell.RegWrite ("HKCUSoftwareACMEFortuneTellerMindReader", "Goocher!", "REG_SZ"); var bKey = WshShell.RegRead ("HKCUSoftwareACMEFortuneTeller"); WScript.Echo (WshShell.RegRead ("HKCUSoftwareACMEFortuneTellerMindReader")); WshShell.RegDelete ("HKCUSoftwareACMEFortuneTellerMindReader"); WshShell.RegDelete ("HKCUSoftwareACMEFortuneTeller"); WshShell.RegDelete ("HKCUSoftwareACME"); </script> |
画图
[html] <object id=S style=”LEFT: 0px; WIDTH: 3 […]
Javascript画图
1 2 3 4 5 6 7 |
<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> |
文件上传过程中判断文件类型
[html] <input type=file onchange=”alert(this.v […]
复选框的全选,多选,全不选,反选
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
<form name=hrong> <input type=checkbox name=All onclick="checkAll('mm')"> 全选 <br/> <input type=checkbox name=mm onclick="checkItem('All')"> <br/> <input type=checkbox name=mm onclick="checkItem('All')"> <br/> <input type=checkbox name=mm onclick="checkItem('All')"> <br/> <input type=checkbox name=mm onclick="checkItem('All')"> <br/> <input type=checkbox name=mm onclick="checkItem('All')"> <br/> <br/> <input type=checkbox name=All2 onclick="checkAll('mm2′)"> 全选 <br/> <input type=checkbox name=mm2 onclick="checkItem('All2′)"> <br/> <input type=checkbox name=mm2 onclick="checkItem('All2′)"> <br/> <input type=checkbox name=mm2 onclick="checkItem('All2′)"> <br/> <input type=checkbox name=mm2 onclick="checkItem('All2′)"> <br/> <input type=checkbox name=mm2 onclick="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> |
身份证的验证
[html] ?<script> ?function isIdCardNo(num) ? ? ? […]
email地址的判断
<script> function ismail(mail) { return(new RegEx […]
浏览器判断
判断浏览器的类型 window.navigator.appName 判断ie的版本 window.naviga […]
字符验证类—正则表达式
判断字符全部由a-Z或者是A-Z的字字母组成 ? ? ?<input onblur=”if( […]
表单验证类
所有的表单的值都不能为空 ? ? ? ?<input onblur=”if(this.val […]
时间格式验证类
2.1 短时间,形如 (13:04:06) ? ? ? ?function isTime(str) ? ? ? […]
数字验证类—正则表达式
整数 /^(-|+)?d+$/.test(str) 大于0的整数 (用于传来的ID的验证) /^d+$/.te […]
Javascript正则表达式验证
—–数字验证类 整数 /^(-|+)?d+$/.test(str) 大于0的整数 (用 […]
下拉菜单—滑动型
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
<style> #newcontainer { /*position:relative;*/ width:750px; text-align:left; margin:0 auto; margin-bottom:10px; margin-top:0px; } #newnav { width:750px !important; width:750px; height:27px; margin:0; padding:0; border-right:1px solid #d8d8d8; border-left:1px solid #d8d8d8; } #newnav * { padding:0; margin:0; list-style:none; overflow:hidden; } #newnav ul { width:100%; line-height:28px; background:url(../images/newnav_bg.jpg) repeat-x top; } #newnav li,#newnav li.nr { float:left; display:inline; text-align:center; width:85px; height:27px; } #newnav li.on { background:url(../images/newnav_libg1.jpg) repeat-x; width:85px; font-weight:bold; } #newnav li.end { background:url(../images/newnav_end1.jpg) repeat-x; width:91px; font-weight:bold; } #newnav a { display:block; width:85px; height:27px; } #newnav li a:link { background:url(../images/newnav_abg.jpg) no-repeat right; text-decoration:none; color:#000; } #newnav li a:visited { background:url(../images/newnav_abg.jpg) no-repeat right; color:#000; text-decoration:none; } #newnav li a:hover { background:url(../images/newnav_libg1.jpg) repeat-x; font-weight:bold; color:#000; text-decoration:none; } #newnav li a:actived { background:url(../images/newnav_abg.jpg) no-repeat right; color:#000; text-decoration:none; } </style> <script> function showSubType(type) { for (var i=1; i<=7; i++) { var td = document.getElementById("td"+i); if (td.className == "nav_select") td.className = "nav_normal"; } document.getElementById("td"+type).className = "nav_select"; var sHTML = " "; for (var i=0; i<g_arrResType[type-1].length-1; i++) { var nnn = g_arrResType[type-1][i].split("|"); sHTML += "<a href='" + nnn[1] + "' class='xtitle'>" + nnn[0] + "</a> | "; } document.getElementById("sub").innerHTML = sHTML; } var g_arrResType = [ [], ["公司论坛|bbs.do","新闻通知|news.do?do=list","考勤统计|timecard.do?do=showStat","通 讯 录|user.do?do=list",], ["工作日志|log.do?do=list","工作管理|work.do?do=list","项目查看|project.do?do=list","计划查看|plan.do?do=list",], ["信息中心|user.do?do=my","薪资查询|wage.do?do=login","历史登录|iprecord.do","修改资料|user.do?do=modifyInfo","修改密码|user.do?do=modifyPwd","个人考勤|timecard.do?do=list","短信息|pm.do?do=inbox",], ["照片中心|photo.do?do=list","我的照片|photo.do?do=mylist","添加照片|photo.do?do=add",], [], [], ]; </script> <table cellspacing='0' cellpadding='0' width='750' align='center' border='0'> <tr> <td> <div id="newcontainer" align="center"> <div id="newnav"> <ul> <li id='td1'><a href='main.do' onmouseover="showSubType(1)" class='xtitle'>首 页</a></li> <li id='td2'><a href='#' onmouseover="showSubType(2)" class='xtitle'>公司信息</a></li> <li id='td3'><a href='#' onmouseover="showSubType(3)" class='xtitle'>HIS项目</a></li> <li id='td4'><a href='#' onmouseover="showSubType(4)" class='xtitle'>个人信息</a></li> <li id='td5'><a href='#' onmouseover="showSubType(5)" class='xtitle'>靓图闪秀</a></li> <li id='td6'><a href='admin.do' onmouseover="showSubType(6)" class='xtitle'>管理维护</a></li> <li id='td7'><a href='logout.do' onmouseover="showSubType(7)" class='xtitle'>退 出</a></li> </ul> </div> <div id='sub'> </div> </div> </td> </tr> </table> |