Run the HTML code device online (ii)

Source: Internet
Author: User

Run the HTML code on line (two) and the previous (a) the same, the key part of the JS code, this time is the operation of all the JS function to focus together. The following is the HTML code:

<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"/><title>Run the HTML code device online (ii)</title><Scripttype= "Text/javascript"src= "Runcode.js"></Script><style>#codeinp{font-size:14px;font-family:' Courier '; }. Btnbar{Margin-top:5px; }a{font-size:14px;text-decoration:None;margin:5px; }</style></Head><BodyID= "Nv_tools"class= "Pg_runcode Widthauto"onkeydown= "if (event.keycode==27) return false;">    <Divclass= "Content">        <DivID= "Code"class= "TextBox">            <Div><textareaID= "CODEINP"rows= "8"cols= "Max">Stick the HTML code here and click Run.</textarea></Div>        </Div>        <Divclass= "Btnbar">            <aID= "Btclear"class= "Btns"href= "javascript:void (0);"Hidefocus= "true">Empty</a>            <aID= "Btrun"class= "Btns hilite"href= "javascript:void (0);"Hidefocus= "true">Run</a>        </Div>    </Div></Body></HTML>

The following is the JS code:

(    function() {window.onload=function()        {            varTips = "Stick the HTML code here and click to run." "; varCODEINP = document.getElementById ("Codeinp"); varBtclear = document.getElementById ("Btclear"); varBtrun = document.getElementById ("Btrun"); //tips disappear after clicking the boxCodeinp.onfocus =function()              {                varCode =Codeinp.value; Code= = Tips && (codeinp.value = "");//when the value in textarea is tips, it is emptied. Description: If the value of the && left expression is true, the value of the right expression is returned.             }; //Recovery TipsCodeinp.onblur =function()//            {                varCode =Codeinp.value; Code= = "" && (Codeinp.value = tips);//when the value in textarea is cleared, it is rewritten as a tips            }; //click "Empty" to empty textareaBtclear.onclick =function() {Codeinp.value= "";//The value in the TextArea box is emptied when you click "Empty"Codeinp.focus ();//cursor focus TEXTAREA box            }; //Click "Run" to runBtrun.onclick =function()            {                varCode =Codeinp.value; if(Code! = Tips)//if the value in textarea is not a tips, run the code, or the popup alert                {                    varNewwin = window.open (', ', ', '); Newwin.opener=NULL;                    Newwin.document.write (code);                Newwin.document.close (); }                Else{alert ("Please fill in the required HTML into the input box and then run!" ");        }            }; }    })();

The effect is as follows:

Run the HTML code device online (ii)

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.