Web page: Super Practical several forms of check effect collection

Source: Internet
Author: User
Web page

It can only be a written qualification.

Program code:

Enter to move the cursor to the next input box

Coded by Windy_sk

function ReportError (msg,url,line) {
var str = ' You have found an error as below: \ n ';
STR + + ' ERR: ' + msg + ' on line: ' + line;
alert (str);
return true;
}

Window.onerror = ReportError;


Document.onkeydown = function () {
if (event.ctrlkey) {
Switch (event.keycode) {
Case://r
RunCode ();
break;
Case://s
Savecode ();
Break
Case A://g
Goto (Prompt (' please input the line number ', ' 1 ');
Break
Case://a
Document.execcommand (' SelectAll ');
Break
Case://c
Document.execcommand (' Copy ');
Break
Case A://x
Document.execcommand (' cut ');
Break
Case://v
Document.execcommand (' Paste ');
Break
Case://z
Document.execcommand (' Undo ');
Break
Case://y
Document.execcommand (' Redo ');
Break
Default:
break;
}
Event.keycode = 0;
Event.returnvalue = false;
}
return;
}


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 =event.srcelement.document.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)
Error Checking code ~~~~~~
if (Sel.parentelement ()!= tmp.parentelement ()) return;
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)
Error Checking code ~~~~~~
if (Sel.parentelement ()!= tmp.parentelement ()) return;
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)
Error Checking code ~~~~~~
if (Sel.parentelement ()!= tmp.parentelement ()) return;
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
}
Return
}


Function RunCode () {
var str = document.getElementById (' Txt_main '). Value;
var Code_win = window.open (' About:blank ');
Code_win.document.open ();
Code_win.document.writeln (' Code_win.document.writeln (' function ReportError (msg,url,line) {\nline-=14;\nvar str= ' you have found an error as below: \\n\\n '; \nstr+= ' Err: ' +msg+ ' on line: ' + [line]; \nalert (str); \nopener.goto (line); \nopener.focus (); \ Nwindow.onerror=null;\nsettimeout (' Self.close () ', ten); \nreturn true;\n} ');
Code_win.document.writeln (' window.onerror = ReportError; ');
Code_win.document.writeln (' <\/script> ');
Code_win.document.writeln (str);
Code_win.document.close ();
return;
}


function Savecode () {
var str = document.getElementById (' Txt_main '). Value;
var Code_win = window.open (' About:blank ', ' _blank ', ' top=10000 ');
Code_win.document.open ();
Code_win.document.writeln (str);
Code_win.document.close ();
Code_win.document.execCommand (' SaveAs ', ', ', ' code.html ');
Code_win.close ();
Return
}


function Goto (LN) {
if (!/^\d+$/.test (LN)) return;
var obj = document.getElementById (' Txt_main ');
var rng = Obj.createtextrange ();
var arr = obj.value.replace (/\r/, '). Split (/\n/);
if (ln>arr.length) ln = arr.length;
var str_tmp = ';
for (var i=0; i Str_tmp + = Arr[i];
}
Rng.movestart (' character ', str_tmp.length+1);
Str_tmp = ';
for (I=LN; i Str_tmp + = Arr[i];
}
Rng.moveend (' character ',-str_tmp.length);
Rng.select ();
Return
}

Window.onload = function () {document.getElementById (' Txt_main '). Value = ' <script>\nalert (') \n<\/script> ';}
</script>
<body>
<table width= ' class= ' list ' border= ' 1 ' bgcolor= ' #eeeeee ' bordercolorlight= ' #000000 ' bordercolordark= ' #FFFFFF ' cellpadding= ' 0 ' cellspacing= ' 0 ' >
<tr bgcolor= ' #cccccc ' >
<TD colspan= ' 2 ' height= ' align= ' center ' ><b>debug textarea</b></td>
</tr>
<tr>
<TD colspan= ' 2 ' >
<table width= ' border= ' 0 ' align= ' center ' >
<tr>
<TD align= ' center ' ><br/>
<textarea id= ' txt_ln ' name= ' content ' rows= ' style= ' width:40px;overflow:hidden;height:200px;border-right:0px; Text-align:right;line-height:14px ' onselectstart= ' This.nextSibling.focus (); return false ' Readonly></textarea ><textarea id= ' txt_main ' name= ' content ' rows= ' cols= ' (Onkeydown=gbcount, This.form.total,this.form.used,this.form.remain); Onkeyup=gbcount (This.form.guestcontent,this.form.total,this.form.used,this.form.remain);></textarea>
Maximum words: <input disabled maxlength=4 name=total size=3 value=20>
Words used: <input disabled maxlength=4 name=used size=3 value=0>
Remaining words: <input disabled maxlength=4 name=remain size=3>
</form>



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.