匹配中文字符的正则表达式: [/u4e00-/u9fa5] 匹配双字节字符(包括汉字在内):[^/x00-/x […]
CSS按钮实例演示
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 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>吹牛b点坑 - CSS按钮实例演示</title> <style type="text/css"> <!-- #menu { width:8em; padding:0.5em; background:#ccc; font-family: "Terminal"; } #menu a, #menu a:visited { display:block; width:7em; color:#669900; text-align:center; background-color:#fff; text-decoration:none; margin:0.5em 0; border-left:0.5em solid #9ab; } #menu a:hover { color:#f00; border-left:0.5em solid #000; } .box { position:relative; } --> </style> </head> <body> <div id="menu"> <div class="box"> <a href="http://liuleng.com/"> 吹牛b点坑 </a> </div> <div class="box"> <a href="http://liuleng.com/"> 首页 </a> </div> <div class="box"> <a href="http://liuleng.com/"> 设计 </a> </div> <div class="box"> <a href="http://liuleng.com/"> 教程 </a> </div> <div class="box"> <a href="http://liuleng.com/"> 资源 </a> </div> </div> </body> </html> |
DOM部分学习
DOM定义对操作一个文档对象的节点结构提供了实用的方法,它提供了像执行对象插入,更新,删除,克隆等这些常用的方 […]
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> |
自由调整编辑框的高度
[html] ? ?<script> ?// 修改编辑栏高度 ?function admin_Si […]
tomcat配置文件
1 – Tomcat Server的组成部分 1.1 – Server A Serve […]
Tomcat的web.xml配置
1 定义头和根元素 2 部署描述符文件内的元素次序 XML头必须是文件中的第一项,DOCTYPE声明必须是第二 […]
关于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 |
<script language="JavaScript"> function delete_confirm(e) { if (event.srcElement.outerText == "删除") event.returnValue = confirm("您确认执行删除操作么?"); } document.onclick = delete_confirm; </script> //可以实现对链接删除的确认,即"删除"两字链接 <script language="JavaScript"> function delete_confirm(e) { if (event.srcElement.value == "删除") event.returnValue = confirm("您确认执行删除操作么?"); } document.onclick = delete_confirm; </script> //可以实现对按钮删除的确认 <script language="JavaScript"> function delete_confirm(e) { if (event.srcElement.value == "删除") event.returnValue = confirm("您确认执行删除操作么?"); else if (event.srcElement.outerText == "删除") event.returnValue = confirm("您确认执行删除操作么?"); } document.onclick = delete_confirm; </script> //实现对链接或按钮删除的确认 <script language="JavaScript"> function delete_confirm(e) { if (event.srcElement.outerText == "删除" || event.srcElement.value == "删除") event.returnValue = confirm("删除后将不能恢复,您确认执行删除操作么?"); } document.onclick = delete_confirm; </script> |
快速精通掌握FRAME的使用
FRAME(框架)是Web上经常会看到的页面结构。使用可视Web开发工具(比如Dreamweaver或者F […]
数据库查询技巧
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 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 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 |
<style rel='stylesheet' type='text/css'> BODY { BORDER-BOTTOM:0px; BORDER-LEFT:0px; BORDER-RIGHT:0px; BORDER-TOP:0px; MARGIN:0px } #menu { BACKGROUND:buttonface; BORDER-BOTTOM:buttonface 1px solid; BORDER-LEFT:buttonface 1px solid; BORDER-RIGHT:buttonface 1px solid; BORDER-TOP:buttonface 1px solid; CURSOR:default; LEFT:0px; POSITION:absolute; TOP:0px } #menu .menu { BACKGROUND:buttonface; BORDER-BOTTOM:buttonhighlight 2px outset; BORDER-LEFT:buttonhighlight 2px outset; BORDER-RIGHT:buttonhighlight 2px outset; BORDER-TOP:buttonhighlight 2px outset; POSITION:absolute } #menu TD { FONT:menu; HEIGHT:20px } #menu .root { BORDER-BOTTOM:buttonface 1px solid; BORDER-LEFT:buttonface 1px solid; BORDER-RIGHT:buttonface 1px solid; BORDER-TOP:buttonface 1px solid; MARGIN:6px; PADDING-BOTTOM:1px; PADDING-LEFT:7px; PADDING-RIGHT:7px; PADDING-TOP:1px } #menu .icon { TEXT-ALIGN:center } #menu .disabled { COLOR:buttonshadow } #menu .more { FONT-FAMILY:webdings; TEXT-ALIGN:right; WIDTH:20px } #menu #handle { BORDER-BOTTOM:buttonshadow 1px solid; BORDER-LEFT:buttonhighlight 1px solid; BORDER-RIGHT:buttonshadow 1px solid; BORDER-TOP:buttonhighlight 1px solid; CURSOR:move; MARGIN:0px; PADDING-BOTTOM:0px; PADDING-LEFT:0px; PADDING-RIGHT:0px; PADDING-TOP:0px } #outerDiv { BORDER-BOTTOM:white 2px inset; BORDER-LEFT:white 2px inset; BORDER-RIGHT:white 2px inset; BORDER-TOP:white 2px inset; HEIGHT:90%; OVERFLOW:auto; POSITION:absolute; WIDTH:100%; Z-INDEX: -1 } </style> <script type='text/javascript'> var activeMenu = null; var activeSub = null; var tempEl; var t; var hideWindowedControls = true; var ie5 = (document.getElementsByTagName != null); //////////////////////////////////////////////////////// //If you wan't different colors than default overload these functions... function menuItemHighlight(el) { el.style.background = "highlight"; el.style.color = "highlighttext"; } function menuItemNormal(el) { el.style.background = ""; el.style.color = ""; } function raiseButton(el) { el.style.borderTop = "1 solid buttonhighlight"; el.style.borderLeft = "1 solid buttonhighlight"; el.style.borderBottom = "1 solid buttonshadow"; el.style.borderRight = "1 solid buttonshadow"; el.style.padding = "1"; el.style.paddingLeft = "7"; el.style.paddingRight = "7"; } function normalButton(el) { el.style.border = "1 solid buttonface"; el.style.padding = "1"; el.style.paddingLeft = "7"; el.style.paddingRight = "7"; } function pressedButton(el) { el.style.borderTop = "1 solid buttonshadow"; el.style.paddingTop = "2"; el.style.borderLeft = "1 solid buttonshadow"; el.style.paddingLeft = "8"; el.style.borderBottom = "1 solid buttonhighlight"; el.style.paddingBottom = "0"; el.style.borderRight = "1 solid buttonhighlight"; el.style.paddingRight = "6"; } //...untill here //////////////////////////////////////////////////////// function cleanUpMenuBar() { for (i = 0; i < menu.rows.length; i++) { for (j = 0; j < menu.rows(i).cells.length; j++) { if (menu.rows(i).cells(j).className == "root") { normalButton(menu.rows(i).cells(j)); } } } showWindowedObjects(true); } function getMenuItem(el) { temp = el; while ((temp != null) && (temp.tagName != "TABLE") && (temp.id != "menubar") && (temp.id != "menu") && (temp.id != "handle")) { if ((temp.tagName == "TR") || (temp.className == "root")) el = temp; temp = temp.parentElement; } return el; } function getSub(el) { temp = el; while ((temp != null) && (temp.className != "sub")) { i f(temp.tagName == "TABLE") el = temp; temp = temp.parentElement; } return el; } function menuClick() { if (event.srcElement == null) return; var el = getMenuItem(event.srcElement); if ((el.className != "disabled") && (el.id != "menubar")) { if (el.className == "root") { if (activeMenu) { raiseButton(el); showWindowedObjects(true); } else pressedButton(el); toggleMenu(el); } else if (el.href) { cleanUpMenuBar(); if (activeMenu) toggleMenu(activeMenu.parentElement); if (el.target) window.open(el.href, el.target); else if (document.all.tags("BASE").item(0) != null) window.open(el.href, document.all.tags("BASE").item(0).target); else window.location = el.href; } } window.event.cancelBubble = true; } //////////////////////////////////////////////////////// // Used to hide the menu when clicked elsewhere function Restore() { if (activeMenu) { toggleMenu(activeMenu.parentElement); cleanUpMenuBar(); } } document.onclick = Restore; //////////////////////////////////////////////////////// function menuOver() { if ((event.fromElement == null) || (event.toElement == null) || (event.fromElement == event.toElement)) return; var fromEl = getMenuItem(event.fromElement); var toEl = getMenuItem(event.toElement); if (fromEl == toEl) return; if ((toEl.className != "disabled") && (toEl.id != "menubar")) { if (toEl.className == "root") { if (activeMenu) { if (toEl.menu != activeMenu) { cleanUpMenuBar(); pressedButton(toEl); toggleMenu(toEl); } } else { raiseButton(toEl); } } else { if ((fromEl != toEl) && (toEl.tagName != "TABLE")) { cleanup(toEl.parentElement.parentElement, false); menuItemHighlight(toEl); toEl.parentElement.parentElement.activeItem = toEl; if (toEl.href) window.status = toEl.href; if (toEl.className == "sub") showSubMenu(toEl, true); } } } } function menuOut() { if ((event.fromElement == null) || (event.toElement == null) || (event.fromElement == event.toElement)) return; var fromEl = getMenuItem(event.fromElement); var toEl = getMenuItem(event.toElement); if (fromEl == toEl) return; if (fromEl.className == "root") { if (activeMenu) { if (fromEl.menu != activeMenu) normalButton(fromEl); } else normalButton(fromEl); } else { if ((fromEl.className != "disabled") && (fromEl.id != "menubar")) { if ((fromEl.className == "sub") && (getSub(toEl) == fromEl.subMenu) || (fromEl.subMenu == toEl.parentElement.parentElement)) return; else if ((fromEl.className == "sub")) { cleanup(fromEl.subMenu, true); menuItemNormal(fromEl); } else if ((fromEl != toEl) && (fromEl.tagName != "TABLE")) menuItemNormal(fromEl); window.status = ""; } } } function toggleMenu(el) { if (el.menu == null) el.menu = getChildren(el); if (el.menu == activeMenu) { if (activeSub) menuItemNormal(activeSub.parentElement.parentElement); cleanup(el.menu, true); activeMenu = null; activeSub = null; // showWindowedObjects(true); } else { if (activeMenu) { cleanup(activeMenu, true); hideMenu(activeMenu); } activeMenu = el.menu; var tPos = topPos(el.menu) + menu.offsetHeight; if ((document.body.offsetHeight - tPos) >= el.menu.offsetHeight) { el.menu.style.pixelTop = (ie5) ? el.offsetHeight + 1 : menu.offsetHeight - el.offsetTop - 2; dir = 2; } else { el.menu.style.pixelTop = (ie5) ? el.offsetTop - el.menu.offsetHeight - 1 : el.offsetTop - el.menu.offsetHeight + 2; dir = 8; } el.menu.style.pixelLeft = (ie5) ? el.offsetLeft - 2 : el.offsetLeft; show(el.menu, dir); showWindowedObjects(false); } } function showSubMenu(el, show) { var dir = 2; temp = el; list = el.children.tags("TD"); el = list[list.length - 1]; if (el.menu == null) el.menu = getChildren(el); temp.subMenu = el.menu; if ((el.menu != activeMenu) && (show)) { activeSub = el.menu; var lPos = leftPos(el.menu); if ((document.body.offsetWidth - lPos) >= el.menu.offsetWidth) { el.menu.style.left = (ie5) ? el.parentNode.offsetWidth : el.offsetParent.offsetWidth; dir = 6; } else { el.menu.style.left = -el.menu.offsetWidth + 3; dir = 4; } var tPos = (ie5) ? topPos(el.menu) + el.offsetTop : topPos(el.menu) + el.offsetParent.offsetTop; // + el.menu.offsetTop; if ((document.body.offsetHeight - tPos) >= el.menu.offsetHeight) el.menu.style.top = (ie5) ? el.offsetTop - 4 : el.offsetParent.offsetTop - 2; else el.menu.style.top = (ie5) ? el.offsetTop + el.offsetHeight - el.menu.offsetHeight : el.offsetParent.offsetTop + el.offsetParent.offsetHeight - el.menu.offsetHeight + 2; showSub(el.menu, dir); } else { show(el.menu, dir); activeSub = null; } } //////////////////////////////////////////////////////// //The following two functions are needed to calculate the position function topPos(el) { var temp = el; var y = 0; while (temp.id != "menu") { temp = temp.offsetParent; y += temp.offsetTop; } return y; } function leftPos(el) { var temp = el; var x = 0; while (temp.id != "menu") { temp = temp.offsetParent; x += temp.offsetLeft; } return x + el.offsetParent.offsetWidth; } //////////////////////////////////////////////////////// function show(el, dir) { if (typeof (fade) == "function") fade(el, true); else if (typeof (swipe) == "function") { tempElSwipe = el; tempDirSwipe = dir; el.style.visibility = "visible"; el.style.visibility = "hidden"; window.setTimeout("tempSwipe()", 0); // swipe(el, dir); } else el.style.visibility = "visible"; } var tempElSwipe, tempDirSwipe; function tempSwipe() { swipe(tempElSwipe, tempDirSwipe); } function showSub(el, dir) { show(el, dir); // swipe(el, dir); // fade(el, true); // el.style.visibility = "visible"; } function cleanup(menu, hide) { if (menu.activeItem) { //If you've been here before if ((menu.activeItem.className == "sub") && (menu.activeItem.subMenu)) { //The active item has a submenu cleanup(menu.activeItem.subMenu, true); //Clean up the subs as well } menuItemNormal(menu.activeItem); } if (hide) { hideMenu(menu); } } function hideMenu(el) { if (typeof (fade) == "function") { fade(el, false); // window.setTimeout(fadeTimer); } else if (typeof (swipe) == "function") { hideSwipe(el); } else el.style.visibility = "hidden"; } function getChildren(el) { var tList = el.children.tags("TABLE"); return tList[0]; } ///////////////////////////////////////////////////////////////////////////// // The rest is just for the moving/docking var dragObject = null; var dragObjectPos = "top"; var tx; var ty; ///////////////////////////////////////////////////////////////////////////// // Fixing sizes and positions window.onload = fixSize; window.onresize = fixSize; function fixSize() { if (dragObjectPos == "top") { outerDiv.style.top = menu.offsetHeight; outerDiv.style.height = document.body.clientHeight - menu.offsetHeight; } else if (dragObjectPos == "bottom") { outerDiv.style.top = 0; outerDiv.style.height = document.body.clientHeight - menu.offsetHeight; menu.style.top = document.body.clientHeight - menu.offsetHeight; } else { outerDiv.style.top = 0; outerDiv.style.height = document.body.clientHeight; } } ///////////////////////////////////////////////////////////////////////////// function document.onmousedown() { if (window.event.srcElement.id == "handle") { dragObject = document.all[window.event.srcElement.getAttribute("for")]; Restore(); //Hide the menus while moving ty = (window.event.clientY - dragObject.style.pixelTop); window.event.returnValue = false; window.event.cancelBubble = true; } else { dragObject = null; } } function document.onmouseup() { if (dragObject) { dragObject = null; } } function document.onmousemove() { if (dragObject) { if (window.event.clientX >= 0) { if ((window.event.clientY - ty) <= 15) { dragObject.style.border = "0 solid buttonface"; dragObject.style.width = "100%"; dragObject.style.top = 0; dragObject.style.left = 0; dragObjectPos = "top"; fixSize(); } else if ((window.event.clientY - ty) >= document.body.clientHeight - menu.offsetHeight - 15) { dragObject.style.border = "0 solid buttonface"; dragObject.style.width = "100%"; dragObject.style.top = document.body.clientHeight - menu.offsetHeight; dragObject.style.left = 0; dragObjectPos = "bottom"; fixSize(); } else { dragObject.style.width = "10px"; dragObject.style.left = window.event.clientX; dragObject.style.top = window.event.clientY - ty; dragObject.style.border = "2px outset white"; dragObjectPos = "float"; fixSize(); } } else { dragObject.style.border = ""; dragObject.style.left = "0"; dragObject.style.top = "0"; } window.event.returnValue = false; window.event.cancelBubble = true; } } //This function si used for hiding windowed controls because they interfere with the menus function showWindowedObjects(show) { if (hideWindowedControls) { var windowedObjectTags = new Array("Select", "IFRAME", "OBJECT", "APPLET", "EMBED"); var windowedObjects = new Array(); var j = 0; for (var i = 0; i < windowedObjectTags.length; i++) { var tmpTags = document.all.tags(windowedObjectTags[i]); if (tmpTags.length > 0) { for (var k = 0; k < tmpTags.length; k++) { windowedObjects[j++] = tmpTags[k]; } } } for (var i = 0; i < windowedObjects.length; i++) { if (!show) windowedObjects[i].visBackup = (windowedObjects[i].style.visibility == null) ? "visible" : windowedObjects[i].style.visibility; windowedObjects[i].style.visibility = (show) ? windowedObjects[i].visBackup : "hidden"; } } } </script> <table cellspacing='1' id='menu' onclick='menuClick()' onmouseout='menuOut()' onmouseover='menuOver()' onselectstart="return false"> <tbody> <tr id='menubar'> <!-- This is a handle. Grab this --> <td class='disabled' style="PADDING-LEFT: 0px; PADDING-RIGHT: 1px"> <div class='disabled' id='handle' style="HEIGHT: 100%; LEFT: 3px; WIDTH: 3px" title="Move me!" for="menu"> </div> </td> <!-- End of handle --> <td class='root'> Demo <table cellspacing='0' class='menu' style="VISIBILITY: hidden"> <tbody> <tr href="javascript:alert('这里可以改成一个链接!')"> <td> <img height='17' src="home.gif" tppabs="http://www.baron.com.cn/javascript/menu/home.gif" width='16'> </td> <td nowrap> You can use icons </td> <td> </td> </tr> <tr class='disabled'> <td> </td> <td nowrap> Disabled menuItems </td> <td> </td> </tr> <tr class='sub'> <td> </td> <td nowrap> Use sub menus </td> <td> <span class='more'>4</span> <table cellspacing='0' class='menu' style="VISIBILITY: hidden"> <tbody> <tr href="javascript:alert('这里可以改成一个链接')"> <td nowrap style="HEIGHT: 20px"> Inside a sub menu </td> </tr> </tbody> </table> </td> </tr> <tr class='disabled'> <td colspan='3'> <hr/> </td> </tr> <tr href="javascript:alert('这里可以改成一个链接')"> <td> </td> <td> Use separators </td> <td> </td> </tr> <tr title="This is really easy"> <td> </td> <td> Use tool tip </td> <td> </td> </tr> </tbody> </table> </td> <!-- Leave this About --> <td class='root'> Help <table cellspacing='0' class='menu' style="VISIBILITY: hidden"> <tbody> <tr class='sub'> <td> <span style="WIDTH: 20px"></span> </td> <td> About </td> <td> <span class='more'>4</span> <table cellspacing='0' class='menu' style="BACKGROUND: black; VISIBILITY: hidden"> <tbody> <tr class='disabled' title=""> <td> <div style="BACKGROUND: black; COLOR: white; FONT-FAMILY: verdana; FONT-SIZE: 12px; MARGIN: 5px; PADDING-BOTTOM: 5px; PADDING-LEFT: 5px; PADDING-RIGHT: 5px; PADDING-TOP: 5px; WIDTH: 200px"> <p style="MARGIN : 5px"> 站长<span style="COLOR: tomato; FONT-WEIGHT: bold">晨曦</span> 欢迎你的光临<a href="mailto:xiaoqinglu@263.net" style="COLOR: white">ChengXi</a>. </p> <p style="BACKGROUND: beige; COLOR: red; FONT-SIZE: 9px; MARGIN: 10px"> 这个菜单只适用与IE4.0或更高版本 </p> <p onclick="bugs.style.display=(bugs.style.display=='')?'none':'';" style="CURSOR: hand; TEXT-DECORATION: underline"> 欢迎再次光临! </p> <p id='bugs' style="DISPLAY: none; MARGIN-LEFT: 20px; MARGIN-TOP: -5px"> www.javascript2000.com 是最大的中文javascript站点 并且每日更新,你一定不可错过 </p> <hr style="COLOR: deepskyblue"> <p style="MARGIN-BOTTOM: -10px; MARGIN-LEFT: 33px; MARGIN-TOP: -12px"> <a href="javascript:if(confirm('http://www.javascript2000.com/ /n/n文件并未依 Teleport Pro 取回,因为 它的域或路径超过开始网址中设置的范围。 /n/n你要从服务器上打开它吗?'))window.location='http://www.javascript2000.com/'" tppabs="http://www.javascript2000.com/" style="COLOR: white; FONT-FAMILY: arial black; FONT-SIZE: 30px; FONT-STYLE: italic; TEXT-DECORATION: none" target='_top'>javascript2000</a> </p> </div> </td> </tr> </tbody> </table> </td> <!-- Till here --> </tr> </tbody> </table> </td> <td class='disabled' width="100%"> </td> </tr> </tbody> </table> <div id='outerDiv'></div> |
JAVA环境变量设置批处理文件
@echo off IF EXIST %1/bin/java.exe ( rem 如输入正确的 Java2SD […]
日历类, 提供日历功能
import javax.swing.*; import java.awt.event.*; import j […]
JSP的学习
防止jSP或SERVLET中的输出被浏览器保存在缓冲区中 <% response.setHeader(& […]
JAVA中的文件操作函数
在jSP中创建目录 Mkdir(String path)
JAVA中的字符串操作函数
判断空值 if isnull(ss) { } else { } 在jsp中判断字符串要使用compareTo方 […]
JAVA中的数组操作函数
/** * 查找指定的元素是否存在于元素数组中 * 使用Object支持各种对象数组 * 示例 * Strin […]
JSP上实现类似ASP中的Global.asa
☆在JSP上实现类似ASP中的Global.asa 这样具有系统事件监听功能的程序并不难,我想这也是很多JSP […]
IO操作的工具类
import java.io.*; public final class StreamUtil { /** * […]
HTTP字符集编码过滤器
import javax.servlet.*; import java.io.IOException; /** […]
处理URL中文参数问题,对中文参数进行编码和解码
import org.apache.commons.codec.base64.Base64; /** * 提供 […]
Md5算法java实现类
package com.test import java.security.*; import java.ma […]
JAVA中的数值操作函数
货币的格式转换(有问题) 控制台输出为: ¥12,345.02 取小数点后几位(四舍五入) /** * 四舍五 […]