1 2 3 4 5 6 7 8 9 10 11 |
function Dvbbs_ViewCode(replyid) { var bodyTag = "<html><head><style type=text/css>.quote{margin:5px 20px;border:1px solid #CCCCCC;padding:5px; background:#F3F3F3 }/nbody{boder:0px}.HtmlCode{margin:5px 20px;border:1px solid #CCCCCC;padding:5px;background:#FDFDDF;font-size:14px;font-family:Tahoma;font-style : oblique;line-height : normal ;font-weight:bold;}/nbody{boder:0px}</style></head><body bgcolor=/"#FFFFFF / " >"; bodyTag += document.getElementById('scode' + replyid).CodeText.value; bodyTag += "</body></html>"; preWin = window.open('preview', '', 'left=0,top=0,width=550,height=400,resizable=1,scrollbars=1, status=1, toolbar=1, menubar=0'); preWin.document.open(); preWin.document.write(bodyTag); preWin.document.close(); preWin.document.title = "查看贴子内容"; preWin.document.charset = "UTF-8"; } |
JavaScript有用小程序集合
事件源对象 event.srcElement.tagName event.srcElement.type 捕获 […]
超级公告
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
<style type="text/css">.t { LINE-HEIGHT:1.4 } BODY { FONT-FAMILY:宋体; FONT-SIZE:9pt; } caption,TD,DIV,form,OPTION,P,TD,BR { FONT-FAMILY:宋体; FONT-SIZE:9pt } INPUT { FONT-SIZE:9pt; } textarea,select { border-width:1; border-color:#000000; background-color:#efefef; font-family:宋体; font-size:9pt; font-style:bold; } #fadeinbox { position:absolute; width:350px; left:0; top:-400px; border:2px #4D76B3; background-color:#F3F6FA; padding:4px; z-index:100; visibility: hidden; } </style> <script> var ie55 = ""; var agent = navigator.userAgent.toLowerCase(); if (document.all) { var version = parseFloat(agent.substr(agent.indexOf("msie") + 5, 3)); if (version >= 5.5) { ie55 = "yes"; } } var displaymode = "oncepersession"; var autohidebox = ["no", 20]; var showonscroll = "yes"; var enablefade = "yes"; var IEfadelength = 1; var Mozfadedegree = 0.05; if (parseInt(displaymode) != NaN) { var random_num = Math.floor(Math.random() * displaymode); } function displayfadeinbox() { var ie = document.all && !window.opera; var dom = document.getElementById iebody = (document.compatMode == "CSS1Compat") ? document.documentElement : document.body; objref = (dom) ? document.getElementById("fadeinbox") : document.all.fadeinbox; var scroll_top = (ie) ? iebody.scrollTop : window.pageYOffset; var docwidth = (ie) ? iebody.clientWidth : window.innerWidth; docheight = (ie) ? iebody.clientHeight : window.innerHeight; var objwidth = objref.offsetWidth; objheight = objref.offsetHeight; objref.style.left = docwidth / 2 - objwidth / 2 + "px"; objref.style.top = scroll_top + docheight / 2 - objheight / 2 + "px"; if (showonscroll == "yes") showonscrollvar = setInterval("staticfadebox()", 50); if (ie55 == "yes" && enablefade == "yes" && objref.filters) { eval(objref.filters[0].duration = IEfadelength); eval(objref.filters[0].Apply()); eval(objref.filters[0].Play()); } objref.style.visibility = "visible"; if (objref.style.MozOpacity) { if (enablefade == "yes") mozfadevar = setInterval("mozfadefx()", 90); else { objref.style.MozOpacity = 1; controlledhidebox(); } } else controlledhidebox(); } function mozfadefx() { if (parseFloat(objref.style.MozOpacity) < 1) objref.style.MozOpacity = parseFloat(objref.style.MozOpacity) + Mozfadedegree; else { clearInterval(mozfadevar); controlledhidebox(); } } function staticfadebox() { var ie = document.all && !window.opera; var scroll_top = (ie) ? iebody.scrollTop : window.pageYOffset; objref.style.top = scroll_top + docheight / 2 - objheight / 2 + "px"; } function hidefadebox() { objref.style.visibility = "hidden"; if (typeof showonscrollvar != "undefined") clearInterval(showonscrollvar); document.cookie = "fadedin=no"; } function controlledhidebox() { if (autohidebox[0] == "yes") { var delayvar = (enablefade == "yes" && objref.filters) ? (autohidebox[1] + objref.filters[0].duration) * 1000 : autohidebox[1] * 1000; setTimeout("hidefadebox()", delayvar); } } function initfunction() { setTimeout("displayfadeinbox()", 100); } 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; } if (displaymode == "oncepersession" && get_cookie("fadedin") == "" || displaymode == "always" && get_cookie("fadedin") != "no" || parseInt(displaymode) != NaN && random_num == 0 && get_cookie("fadedin") != "no") { if (window.addEventListener) window.addEventListener("load", initfunction, false); else if (window.attachEvent) window.attachEvent("onload", initfunction); else if (document.getElementById) window.onload = initfunction; document.cookie = "fadedin=yes"; } </script> <div id='fadeinbox' style="filter:progid:DXImageTransform.Microsoft.RandomDissolve(duration=1) progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135) ; -moz-opacity:0"> <table border='0' width='350' cellspacing='0' cellpadding='2' bgcolor='#4D76B3'> <tr> <td width='100%'> <table border='0' width='100%' bgcolor='#F3F6FA' cellspacing='4' cellpadding='2'> <tr> <td width='100%'> <center> <b> <font color='#990000'> * 超 级 公 告 * </font>< /b> </center> </td> </tr> </table> </td> </tr> </table> </div> |
Javascript复制粘贴
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 |
<script type="text/javascript"> function std_playUrl(obj) { if (obj == null) { var ok = window.clipboardData.setData("Text", document.location.toString()); if (ok == true) { alert("当前网址已被复制!"); } } else { var url = window.clipboardData.getData("Text"); if (url == null) { alert("剪切板文本内容为空!"); return false; } var re1 = /^((http|https|ftp|rtsp|mms|pmn):(///|////)[A-Za-z0-9/./=/?%/-&_~`@/]/':+!]+)/ig; var re2 = /([a-zA-Z0-9_][.](/w) + [.]{1,}(net | com | cn | org | cc)((( //[/~]*|//[/~]*)(/w)+)|[.](/w)+)*(((([?](/w)+){1}[=]*))*((/w)+){1}([/&](/w)+[/=](/w)+)*)*)/ig; var t1 = re1.test(url), t2 = re2.test(url); if (!t1 && !t2) { alert("剪切板内容不是网址,请检查!"); return false; } if (confirm("确认要打开以下网址? / n / n" + url)) { obj.href = (t1 ? "":"http://")+url; obj.target="_blank"; return true } return false; } } document.write(' <span style="border:dotted 1px;padding:2px"> <a href=javascript:std_playUrl() title=复制本页URL>复制本页地址</a> <a href=# onmouseover=this.href="#" onclick="return std_playUrl(this)" target=_blank title=转到剪切版URL>粘贴</a> </span>'); </script> |
页面右边的滑动按钮
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<script type="text/javascript"> //右边的滑动按钮 //IE可用 var suspendcode = " <div id = backi style = 'right: 0px; POSITION: absolute; TOP: 200px;' > "; suspendcode += "<a href = 'javascript: scroll(0, 0)'title = '顶部' > <font color = #CC0066 > ▲ </font></a > "; suspendcode += "<a href = 'javascript: history.back()'title = '返回上次出处' > <font color = #CC0066 > ■ </font></a > "; suspendcode += "<a href = 'javascript: scroll(0, 2000)'title = '底部' > <font color = #CC0066 > ▼ </font></a > </div>"; document.write(suspendcode); lastScrollY = 0; function heartBeat() { diffY = document.body.scrollTop; percent = .1 * (diffY - lastScrollY); if (percent > 0) percent = Math.ceil(percent); else percent = Math.floor(percent); document.all.backi.style.pixelTop += percent; lastScrollY = lastScrollY + percent; } window.setInterval("heartBeat()", 1); </script> <p style="height:800px;">1</p> <p style="height:800px;">1</p> <p style="height:800px;">1</p> |
复制粘贴
[html] ?<script language=javascript> ? ?function […]
分时问候
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 |
<script type="text/javascript"> now = new Date(), hour = now.getHours() if (hour < 6) { document.write("凌晨好!") } else if (hour < 9) { document.write("早上好!") } else if (hour < 12) { document.write("上午好!") } else if (hour < 14) { document.write("中午好!") } else if (hour < 17) { document.write("下午好!") } else if (hour < 19) { document.write("傍晚好!") } else if (hour < 22) { document.write("晚上好!") } else { document.write("夜里好!") } </script> |
阅读式公告栏
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 136 137 138 139 140 141 142 143 144 145 146 147 |
<script type="text/javascript"> var TextNumber = 0; // used to track position in message var i = 0; // used to cycle thru messages var TextNumber = -1; // array of messages var TextInput = new Object(); // used to load manipulate message var HelpText = ""; // used to load message var Text = ""; // length of timeout (smaller is faster) var Speed=50; // used to display message number var message=0; // used to position text in ver 2.0 var addPadding="/r/n"; // Each element of TextInput represents a single message. TextInput[0] = "消息1"; TextInput[1] = "消息2"; TextInput[2] = "消息3"; TextInput[3] = "消息4"; TextInput[4] = "消息5"; TextInput[5] = "消息6"; TextInput[6] = "消息7"; TextInput[7] = "消息8"; TotalTextInput = 7; // (0, 1, 2, 3, 4, 5, 6, 7) // Positioning and speed vary between versions. var Version = navigator.appVersion; if (Version.substring(0, 1)==3) { Speed=200; addPadding=""; } for (var addPause = 0; addPause <= TotalTextInput; addPause++) { TextInput[addPause] = addPadding + TextInput[addPause]; } var TimerId var TimerSet = false; // Called by >>> button (display next message) . function nextMessage() { if (!TimerSet) { TimerSet = true; clearTimeout(TimerId); if (TextNumber >= TotalTextInput) { alert("This is the end of the list!"); TimerSet = false; } else { TextNumber += 1; message = TextNumber + 1; document.forms[0].elements[2].value = message; Text = TextInput[TextNumber]; HelpText = Text; } teletype(); } } // Gets and displays character from rollMessage() . // Variable Speed controls length of timeout and thus the speed of typing. function teletype() { if (TimerSet) { Text = rollMessage(); TimerId = setTimeout("teletype()", Speed); document.forms[0].elements[0].value = Text; } } // Pulls one character at a time from string and returns (as Text) to function teletype() for displaying. function rollMessage() { i++; var CheckSpace = HelpText.substring(i - 1, i); CheckSpace = "" + CheckSpace; if (CheckSpace == "") { i++; } if (i >= HelpText.length + 1) { TimerSet = false; Text = HelpText.substring(0, i); i = 0; return (Text); } Text = HelpText.substring(0, i); return (Text); } // Initially called by onLoad in BODY tag to load title. function initTeleType() { Text = "/r/n Manual Tele - Type Display"; document.forms[0].elements[0].value = Text; } // Called by <<< button (get previous message). function lastMessage() { if (!TimerSet && TextNumber != -1) { TimerSet = true; clearTimeout(TimerId); if (TextNumber <= 0) { alert("This is the beginning of the list!"); TimerSet = false; } else { TextNumber -= 1; message = TextNumber + 1; document.forms[0].elements[2].value = message; Text = TextInput[TextNumber]; HelpText = Text; } teletype(); } } </script> <form> <table cellspacing="0" cellpadding="0" width="17%"> <tr> <td width="100%" colspan="3" valign="top"> <textarea name="teletype" rows="3" cols="28" wrap="yes"></textarea> </td> </tr> <tr align="center"> <td width="40%" valign="top" bgcolor="#0000A0"> <input type="button" value="公告栏" onclick="lastMessage()"> </td> <td width="30%" bgcolor="#0000A0" valign="top"> <input type="text" value="共8条" size="5" name="1"> </td> <td width="30%" bgcolor="#0000A0" valign="top"> <input type="button" value="阅' 读" onclick="nextMessage()"> </td> </tr> </table> </form> |
状态栏里的动态欢迎语
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 |
<script type = "text/javascript"> var POSITION = 100; var DELAY = 5; var MESSAGE = "欢迎光临! Welcome to WWW.HELPOR.NET "; var scroll = new statusMessageObject(); function statusMessageObject(p, d) { this.msg = MESSAGE; this.out = " "; this.pos = POSITION; this.delay = DELAY; this.i = 0; this.reset = clearMessage; } function clearMessage() { this.pos = POSITION; } function scroller() { for (scroll.i = 0; scroll.i < scroll.pos; scroll.i++) { scroll.out += " "; } if (scroll.pos >= 0) { scroll.out += scroll.msg; } else { scroll.out = scroll.msg.substring(-scroll.pos, scroll.msg.length); } window.status = scroll.out; scroll.out = " "; scroll.pos--; if (scroll.pos < -(scroll.msg.length)) { scroll.reset(); } setTimeout('scroller()', scroll.delay); } function snapIn(jumpSpaces, position) { var msg = scroll.msg; var out = ""; for (var i = 0; i < position; i++) { out += msg.charAt(i); } for (i = 1; i < jumpSpaces; i++) { out += " "; } out += msg.charAt(position); window.status = out; if (jumpSpaces <= 1) { position++; if (msg.charAt(position) == ' ') { position++; } jumpSpaces = 100 - position; } else if (jumpSpaces > 3) { jumpSpaces *= .75; } else { jumpSpaces--; } if (position != msg.length) { var cmd = "snapIn(" + jumpSpaces + "," + position + ")"; scrollID = window.setTimeout(cmd, scroll.delay); } else { window.status = ""; jumpSpaces = 0; position = 0; cmd = "snapIn(" + jumpSpaces + "," + position + ")"; scrollID = window.setTimeout(cmd, scroll.delay); return false } return true } snapIn(100, 0); </script> |
状态栏和标题栏
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 |
<script type="text/javascript"> //谢谢你对我做的特效感兴趣,可以任意拷贝,不过要多多来我的网页呀! var speed = 100; //Delay Between Every word var pause = 1000; //Delay Between EveryLine var timerID = null; var bannerRunning = false; var ar = new Array(); ar[0] = "Welcome to http: //yinghua2001.126.com!!!"; ar[1] = " -= 〓≈化学世界·浪漫樱花≈〓 = -你的爱好,我的目标!!!"; ar[2] = "化学试题集化学图片趣味化学化学原理化学实验仪器分析化学工具谱图谱库化学教育生物化学…您想要的,天河网都有!"; ar[3] = "希望能得到您的支持,谢谢!!! ^ - ^ "; var currentMessage = 0; var offset = 0; function stopBanner() { if (bannerRunning) { clearTimeout(timerID); } bannerRunning = false; } function startBanner() { stopBanner(); showBanner(); } function showBanner() { var text = ar[currentMessage]; if (offset < text.length) { if (text.charAt(offset) == "") offset++; var partialMessage = text.substring(0, offset + 1); window.status = partialMessage; offset++; timerID = setTimeout("showBanner()", speed); bannerRunning = true; } else { offset = 0; currentMessage++; if (currentMessage == ar.length) currentMessage = 0; timerID = setTimeout("showBanner()", pause); bannerRunning = true; } } startBanner(); //document.write('<meta http-equiv=refresh content=600; url=self>') title_tmp1 = document.title; if (title_tmp1.indexOf(" >> ") != -1) { title_tmp2 = title_tmp1.split(" >> "); title_last = "— > " + title_tmp2[1]; title_last = title_last + "— > " + title_tmp2[2]; } else { if (title_tmp1.indexOf("——") != -1) { title_tmp2 = title_tmp1.split("——"); title_last = "— > " + title_tmp2[1]; if (title_last == "— > ") { title_last = "— > "; } if (title_last == "— > ") { title_last = "— > "; } } else { title_last = "——∷∷化学世界·浪漫樱花…–欢迎你的光临"; } } title_new = "化学世界·浪漫樱花" + title_last + ""; step = 0; function flash_title() { step++; if (step == 9) { step = 1; } if (step == 1) { document.title = '◆◇◇◇◇' + title_new + '◇◇◇◇◆'; } if (step == 2) { document.title = '◇◆◇◇◇' + title_new + '◇◇◇◆◇'; } if (step == 3) { document.title = '◇◇◆◇◇' + title_new + '◇◇◆◇◇'; } if (step == 4) { document.title = '◇◇◇◆◇' + title_new + '◇◆◇◇◇'; } if (step == 5) { document.title = '◇◇◇◇◆' + title_new + '◆◇◇◇◇'; } if (step == 6) { document.title = '◇◇◇◆◇' + title_new + '◇◆◇◇◇'; } if (step == 7) { document.title = '◇◇◆◇◇' + title_new + '◇◇◆◇◇'; } if (step == 8) { document.title = '◇◆◇◇◇' + title_new + '◇◇◇◆◇'; } setTimeout("flash_title()", 200); } flash_title(); </script> |
框架自动增长
<script> window.onload = function() { parent.docu […]
marquee标记
<marquee aligh=left|center|right|top|bottom bgcolor= […]
Input高级限制级用法
1.取消按钮按下时的虚线框 在input里添加属性值 hideFocus 或者 HideFocus=tr […]
图片自动调整的模式
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 |
//图片自动调整的模式,1为按比例调整 ,2 按大小调整。 var resizemode = 1 function imgresize(o) { if (resizemode == 2 || o.onmousewheel) { if (o.width > 500) { o.style.width = '500px'; } if (o.height > 800) { o.style.height = '800px'; } } else { var parentNode = o.parentNode.parentNode if (parentNode) { if (o.offsetWidth >= parentNode.offsetWidth) o.style.width = '98%'; } else { var parentNode = o.parentNode if (parentNode) { if (o.offsetWidth >= parentNode.offsetWidth) o.style.width = '98%'; } } } } function bbimg(o) { var zoom = parseInt(o.style.zoom, 10) || 100; zoom += event.wheelDelta / 12; if (zoom > 0) o.style.zoom = zoom + '%'; return false; } function imgzoom(img, maxsize) { var a = new Image(); a.src = img.src if (a.width > maxsize * 4) { img.style.width = maxsize; } else if (a.width >= maxsize) { img.style.width = Math.round(a.width * Math.floor(4 * maxsize / a.width) / 4); } return false; } |
HTML过滤函数
[code] ?//HTML过滤函数 ?function HTML(text) ?{ ? text = tex […]
设置文件上传个数的效果
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 |
<style type="text/css">td { font-size:9pt } a { color:#000000; text-decoration:none } a:hover { text-decoration:underline } .tx { height:16px; width:30px; border-color:black black #000000; border-top-width:0px; border-right-width:0px; border-bottom-width:1px; border-left-width:0px; font-size:9pt; background-color:#eeeeee; color:#0000FF } .bt { font-size:9pt; border-top-width:0px; border-right-width:0px; border-bottom-width:0px; border-left-width:0px; height:16px; width:80px; background-color:#eeeeee; cursor:hand } .tx1 { height:20px; width:30px; font-size:9pt; border:1px solid; border-color:black black #000000; color: #0000FF } </style> <form name="form1" method="post" action="upfile.asp" enctype="multipart/form-data"> <input type="hidden" name="act" value="upload"> <table width="71%" border="1" cellspacing="0" cellpadding="5" align="center" bordercolordark="#CCCCCC" bordercolorlight="#000000"> <tr align="left" valign="middle" bgcolor="#eeeeee"> <td bgcolor="#eeeeee" height="92"> <script language="javascript"> function setid() { str = ''; if (!window.form1.upcount.value) window.form1.upcount.value = 1; for (i = 1; i <= window.form1.upcount.value; i++) str += '文件' + i + ': <input type = "file" name = "file' + i + '" style = "width: 400" class = "tx1" > '; window.upid.innerHTML = str + ''; } </script> <li> 需要上传的个数 <input type="text" name="upcount" class="tx" value="1"><input type="button" name="Button" class="bt" onclick="setid();" value="· 设定 ·"></li> <li>上传到: <input type="text" name="filepath" class="tx" style="width:350" value=""></li> </td> </tr> <tr align="center" valign="middle"> <td align="left" id="upid" height="122"> 文件1: <input type="file" name="file1" style="width:400" class="tx1" value=""> </td> </tr> <tr align="center" valign="middle" bgcolor="#eeeeee"> <td bgcolor="#eeeeee" height="24"> <input type="submit" name="Submit" value="·' 提交 ·" class="bt"><input type="reset" name="Submit2" value="·' 重执 ·" class="bt"> </td> </tr> </table> </form> |
页面选择radio单选选中的值
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<script type="text/javascript"> function testFunc() { var obj = document.all.finish; for (i = 0; i < obj.length; i++) { if (obj[i].checked) { alert(obj[i].value); } } } </script> <input type=radio name=finish value=1> <input type=radio name=finish value=2> <input type=radio name=finish value=3> <input type=button name=bu value=click onclick="testFunc();"> |
跟随鼠标的文字
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 |
<style> .spanstyle{font-size: 9pt; position: absolute; top: -50px; visibility:visible} </style> <script type="text/javascript"> //IE浏览器专用 var message = "跟随鼠标的文字"; var x, y; var step = 12; var flag = 0; message = message.split(""); var xpos = new Array(); for (i = 0; i <= message.length - 1; i++) { xpos[i] = -50; } var ypos = new Array(); for (i = 0; i <= message.length - 1; i++) { ypos[i] = -50; } function handlerMM(e) { x = (document.layers) ? e.pageX : document.body.scrollLeft + event.clientX + 20; y = (document.layers) ? e.pageY : document.body.scrollTop + event.clientY; flag = 1; } function makesnake() { if (flag == 1 && document.all) { for (i = message.length - 1; i >= 1; i--) { xpos[i] = xpos[i - 1] + step; ypos[i] = ypos[i - 1]; } xpos[0] = x + step; ypos[0] = y; for (i = 0; i <= message.length - 1; i++) { var thisspan = eval("span" + (i) + ".style"); thisspan.posLeft = xpos[i]; thisspan.posTop = ypos[i]; thisspan.color = Math.random() * 255 * 255 * 255 + Math.random() * 255 * 255 + Math.random() * 255; } } else if (flag == 1 && document.layers) { for (i = message.length - 1; i >= 1; i--) { xpos[i] = xpos[i - 1] + step; ypos[i] = ypos[i - 1]; } xpos[0] = x + step; ypos[0] = y; for (i = 0; i < message.length - 1; i++) { var thisspan = eval("document.span" + i); thisspan.left = xpos[i]; thisspan.top = ypos[i]; thisspan.color = Math.random() * 255 * 255 * 255 + Math.random() * 255 * 255 + Math.random() * 255; } } } for (i = 0; i <= message.length - 1; i++) { document.write(" <span id = 'span" + i + "'class = 'spanstyle' > "); document.write(message[i]); document.write(" </span>"); } if (document.layers) { document.captureEvents(Event.MOUSEMOVE); } document.onmousemove = handlerMM; function pageonload() { makesnake(); window.setTimeout("pageonload();", 2); } </script> <body bgcolor="#FFFFFF" text="#000000" link=" #000000" vlink="#000000" alink="#000000" onload=" javascript:pageonload();"> |
AJAX远程读取基本函数
[code] ?<%@LANGUAGE=”VBSCRIPT” CODEPAGE= […]
汉字排序
[html] ?<html> ?<head> ?<title>汉字排序&l […]
Javascript表单检查
[code] ?//函数名:chksafe ?//功能介绍:检查是否含有”‘̶ […]
正则表达式学习
匹配中文字符的正则表达式: [/u4e00-/u9fa5] 匹配双字节字符(包括汉字在内):[^/x00-/x […]
DOM自动生成表格
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 |
<html> <body onload="init()"> <script defer> function init() { var tbl, tbody, tr, td, text, i, max; max = 10; var theDoc = document; var theBody = theDoc.body; tbl = theDoc.createElement("TABLE"); tbl.border = "1"; tbody = theDoc.createElement("TBODY"); tbl.insertBefore(tbody, null); theBody.insertBefore(tbl, null); for (i = 0; i < max; i++) { tr = theDoc.createElement("TR"); td = theDoc.createElement("TD"); text = theDoc.createTextNode("Text"); tbody.insertBefore(tr, null); tr.insertBefore(td, null); td.insertBefore(text, null); } } </script> </body> </html> |
Javascript使表格数据排序
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 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> <title>sort table</title> <style type="text/css"> a { color:#000000; font-weight:bold; text-decoration:none; } /* Sortable tables */ table.sortable a.sortheader { background-color:#eee; color:#666666; font-weight:bold; text-decoration:none; display:block; } table.sortable span.sortarrow { color:black; text-decoration:none; } </style> <script language="javascript"> addEvent(window, "load", sortables_init); var SORT_COLUMN_INDEX; function sortables_init() { // Find all tables with class sortable and make them sortable if (!document.getElementsByTagName) return; tbls = document.getElementsByTagName("table"); for (ti = 0; ti < tbls.length; ti++) { thisTbl = tbls[ti]; if (((' ' + thisTbl.className + ' ').indexOf("sortable") != -1) && (thisTbl.id)) { //initTable(thisTbl.id); ts_makeSortable(thisTbl); } } } function ts_makeSortable(table) { if (table.rows && table.rows.length > 0) { var firstRow = table.rows[0]; } if (!firstRow) return; // We have a first row:assume it's the header,and make its contents clickable links for (var i = 0; i < firstRow.cells.length; i++) { var cell = firstRow.cells[i]; var txt = ts_getInnerText(cell); cell.innerHTML = '<a href="#" class="sortheader" ' + 'onclick="ts_resortTable(this,' + i + ');return false;">' + txt + '<span class="sortarrow"></span></a>'; } } function ts_getInnerText(el) { if (typeof el == "string") return el; if (typeof el == "undefined") { return el }; if (el.innerText) return el.innerText; //Not needed but it is faster var str = ""; var cs = el.childNodes; var l = cs.length; for (var i = 0; i < l; i++) { switch (cs[i].nodeType) { case 1: //ELEMENT_NODE str += ts_getInnerText(cs[i]); break; case 3: //TEXT_NODE str += cs[i].nodeValue; break; } } return str; } function ts_resortTable(lnk, clid) { // get the span var span; for (var ci = 0; ci < lnk.childNodes.length; ci++) { if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci]; } var spantext = ts_getInnerText(span); var td = lnk.parentNode; var column = clid || td.cellIndex; var table = getParent(td, 'TABLE'); // Work out a type for the column if (table.rows.length <= 1) return; var itm = ts_getInnerText(table.rows[1].cells[column]); sortfn = ts_sort_caseinsensitive; if (itm.match(/^/d/d[/-]/d/d[/-]/d/d/d/d$/)) sortfn = ts_sort_date; if (itm.match(/^/d/d[/-]/d/d[/-]/d/d$/)) sortfn = ts_sort_date; if (itm.match(/^[?]/)) sortfn = ts_sort_currency; if (itm.match(/^[/d/.]+$/)) sortfn = ts_sort_numeric; SORT_COLUMN_INDEX = column; var firstRow = new Array(); var newRows = new Array(); for (i = 0; i < table.rows[0].length; i++) { firstRow[i] = table.rows[0][i]; } for (j = 1; j < table.rows.length; j++) { newRows[j - 1] = table.rows[j]; } newRows.sort(sortfn); if (span.getAttribute("sortdir") == 'down') { ARROW = ' ↑'; newRows.reverse(); span.setAttribute('sortdir', 'up'); } else { ARROW = ' ↓'; span.setAttribute('sortdir', 'down'); } // We appendChild rows that already exist to the tbody,so it moves them rather than creating new ones // don't do sortbottom rows for (i = 0; i < newRows.length; i++) { if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) table.tBodies[0].appendChild(newRows[i]); } // do sortbottom rows only for (i=0; i < newRows.length; i++) { if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) table.tBodies[0].appendChild(newRows[i]); } // Delete any other arrows there may be showing var allspans = document.getElementsByTagName("span"); for (var ci = 0; ci < allspans.length; ci++) { if (allspans[ci].className == 'sortarrow') { if (getParent(allspans[ci], "table") == getParent(lnk, "table")) { // in the same table as us? allspans[ci].innerHTML = ' '; } } } span.innerHTML = ARROW; } function getParent(el, pTagName) { if (el == null) return null; else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) // Gecko bug,supposed to be uppercase return el; else return getParent(el.parentNode, pTagName); } function ts_sort_date(a, b) { // y2k notes: two digit years less than 50 are treated as 20XX,greater than 50 are treated as 19XX aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]); bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]); if (aa.length == 10) { dt1 = aa.substr(6, 4) + aa.substr(3, 2) + aa.substr(0, 2); } else { yr = aa.substr(6, 2); if (parseInt(yr) < 50) { yr = '20' + yr; } else { yr = '19' + yr; } dt1 = yr + aa.substr(3, 2) + aa.substr(0, 2); } if (bb.length == 10) { dt2 = bb.substr(6, 4) + bb.substr(3, 2) + bb.substr(0, 2); } else { yr = bb.substr(6, 2); if (parseInt(yr) < 50) { yr = '20' + yr; } else { yr = '19' + yr; } dt2 = yr + bb.substr(3, 2) + bb.substr(0, 2); } if (dt1 == dt2) return 0; if (dt1 < dt2) return -1; return 1; } function ts_sort_currency(a, b) { aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g, ''); bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g, ''); return parseFloat(aa) - parseFloat(bb); } function ts_sort_numeric(a, b) { aa = parseFloat(ts_getInnerText(a.cells[SORT_COLUMN_INDEX])); if (isNaN(aa)) aa = 0; bb = parseFloat(ts_getInnerText(b.cells[SORT_COLUMN_INDEX])); if (isNaN(bb)) bb = 0; return aa - bb; } function ts_sort_caseinsensitive(a, b) { aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase(); bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase(); if (aa == bb) return 0; if (aa < bb) return -1; return 1; } function ts_sort_default(a, b) { aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]); bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]); if (aa == bb) return 0; if (aa < bb) return -1; return 1; } function addEvent(elm, evType, fn, useCapture) // addEvent and removeEvent // cross-browser event handling for IE5+,NS6 and Mozilla // By Scott Andrew { if (elm.addEventListener) { elm.addEventListener(evType, fn, useCapture); return true; } else if (elm.attachEvent) { var r = elm.attachEvent("on" + evType, fn); return r; } else { alert("Handler could not be removed"); } } </script> </head> <body> <p> 点击标题排序 </p> <table width="481" border="1" cellpadding="0" cellspacing="3" id="mytable" class="sortable"> <tbody> <tr> <th width="165"> Name </th> <th width="101"> Salary </th> <th width="101" align="center"> Extension </th> <th width="99" align="center"> Start date </th> </tr> <tr> <td> Bloggs,Fred </td> <td> $12000.00 </td> <td align="center"> 1353 </td> <td align="center"> 18/08/2003 </td> </tr> <tr> <td> Turvey,Kevin </td> <td> $191200.00 </td> <td align="center"> 2342 </td> <td align="center"> 02/05/1979 </td> </tr> <tr> <td> Mbogo,Arnold </td> <td> $32010.12 </td> <td align="center"> 2755 </td> <td align="center"> 09/08/1998 </td> </tr> <tr> <td> Shakespeare,Bill </td> <td> $122000.00 </td> <td align="center"> 3211 </td> <td align="center"> 12/11/1961 </td> </tr> <tr> <td> Shakespeare,Hamnet </td> <td> $9000 </td> <td align="center"> 9005 </td> <td align="center"> 01/01/2002 </td> </tr> <tr> <td> Fitz,Marvin </td> <td> $3300 </td> <td align="center"> 5554 </td> <td align="center"> 22/05/1995 </td> </tr> </tbody> </table> </body> </html> |
自由调整编辑框Textarea的高度
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 |
<script> // 修改编辑栏高度 function admin_Size(num, objname) { var obj = document.getElementById(objname) if (parseInt(obj.rows) + num >= 3) { obj.rows = parseInt(obj.rows) + num; } if (num > 0) { obj.width = "90%"; } } </script> <table> <tr> <td class="forumrowHighlight" align="right" valign="top"> 模板_结束标记部分 </td> <td class="forumrowHighlight"> <textarea name="Skin_Footer" ID="Skin_Footer" style="width:100%;" rows="3"> </textarea> <a href="javascript:admin_Size(-3,'Skin_Footer')">减少</a> <a href="javascript:admin_Size(3,'Skin_Footer')">增加</a> </td> </tr> </table> |