Text input box _ javascript tips for displaying row numbers

Source: Internet
Author: User
Text input box for displaying row numbers

<HTML> <HEAD> <TITLE> DirMap </TITLE> <meta http-equiv = 'content-type' Content = 'text/html; charset = gb2312 '> </HEAD> <style> * {font-size: 12px} body {margin: 10px; padding: 0px} A {COLOR: black; TEXT-DECORATION: none;} A: hover {COLOR: black; TEXT-DECORATION: none;} A: link {TEXT-DECORATION: none} A: visited {TEXT-DECORATION: none} table. list {cursor: default; border: 1px solid # cccccc backgro Und-color: # cccccc; border-collapse: collapse; border-Color: # cccccc;} </style> script function check_form () {var the_form = document. forms [0]; if (! /^ [\ W \.] + $/. test (the_form.name.value) {alert ('bad File Name! '); The_form.name.focus (); return false;} if (! /^ [0-7] {3} $/. test (the_form.attrib.value) {alert ('bad File Attrib! '); The_form.attrib.focus (); return false;} if (the_form.del.checked) {return confirm ('Are you sure to delete the file? ');} Return true;} function show_ln () {var txt_ln = document. getElementById ('txt _ ln '); var txt_main = document. getElementById ('txt _ main'); txt_ln.scrollTop = txt_main.scrollTop; while (txt_ln.scrollTop! = Txt_main.scrollTop) {txt_ln.value + = (I ++) + '\ n'; txt_ln.scrollTop = txt_main.scrollTop;} return;} function editTab () {var code, sel, tmp, r var tabs = ''event. returnValue = false sel ready event.srcelement.doc ument. selection. createRange () r = event. srcElement. createTextRange () switch (event. keyCode) {case (8): if (! (Sel. getClientRects (). length> 1) {event. returnValue = true return} code = sel. text tmp = sel. duplicate () tmp. moveToPoint (r. getBoundingClientRect (). left, sel. getClientRects () [0]. top) sel. setEndPoint ('starttostart', tmp) sel. text = sel. text. replace (/^ \ t/gm, '') code = code. replace (/^ \ t/gm ,''). replace (/\ r \ n/g, '\ R') r. findText (code) r. select () break case (9): if (sel. getClientRects (). length> 1) {code = sel. text tmp = sel. duplicate () tmp. moveToPoint (r. getBoundingClientRect (). left, sel. getClientRects () [0]. top) sel. setEndPoint ('starttostart', tmp) sel. text = '\ t' + sel. text. replace (/\ r \ n/g, '\ r \ t') code = code. replace (/\ r \ n/g, '\ r \ t') r. findText (code) r. select ()} else {sel. text = '\ t' sel. select ()} break case (13): tmp = sel. duplicate () tmp. moveToPoint (r. getBoundingClientRect (). left, sel. getClientRects () [0]. top) tmp. setEndPoint ('endtoend', sel) for (var I = 0; tmp. text. match (/^ [\ t] +/g) & I <tmp. text. match (/^ [\ t] +/g) [0]. length; I ++) tabs + = '\ t' sel. text = '\ r \ n' + tabs sel. select () break default: event. returnValue = true break} script <BODY> <table width = '000000' class = 'LIST' border = '1' bgcolor = '# eeeeee 'bordercolorlight =' #700 'bordercolordark = '# ffff' cellpadding = '0' cellspacing = '0'> <tr bgcolor =' # cccccccc'> <td colspan = '2' height = '20'> <p align = 'center'> <B> File Information </B> </p> </td> </tr> <td colspan = '2'> </td> </tr> </table> </BODY> </HTML>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.