This article describes the JS implementation can directly display the Web page code operation effect of the HTML code preview function. Share to everyone for your reference. Specifically as follows:
JavaScript implementation of HTML code preview, directly on the Web page to display the effect of the operation of the code, such as click on the "Run code" after the effect, use, you just need to run the HTML code copy into the text box, click the corresponding function button can be.
The effect is as shown in the following illustration:
The specific code is as follows:
<HTML> <HEAD> <TITLE> Direct page display </TITLE> <style type= "Text/css" > body{margin-top:0px; font-size:9pt; margin-left:4px; margin-right:0px; font-family: "Microsoft Ya Hei"} a{font-weight:400; font-size:13px; Color:black; Text-decoration:none} a:hover{font-weight:400; font-size:13px; color:red; Text-decoration:underline} A:active{cursor:hand; COLOR: #ff0033}. Style1{color: #0000FF; font-size:40px;}. style2{font-weight:bold;font-size:30px} </STYLE> <meta http-equiv=content-type content= "text/html; charset=gb2312 "> </HEAD> <BODY> <CENTER> <span class=" STYLE1 "><font face= official script > direct page display </FONT></span> </CENTER><BR> <CENTER> <table style= "Border-collapse:collapse" bordercolor= #111111 cellspacing=0 cellpadding=0 border=0 borderlight= "green" > <TBODY> <TR> <td Alig N=middle><span class= "STYLE2" ><font color=red> Please enter the HTML code in the following window </font></span></td > </tr> <TR> <td align=middle> <script language=javascript> function Trestart () {if (SCRIPT) {Clea R = Confirm (Are you sure you want to clear it?)
",'');
if (clear) {document.script.reset ();
Document.script.value = "";
}} function Test () {{temp = Document.script.tester.value;
Testwin= open ("", "Testwin", "Status=no,menubar=yes,toolbar=no");
Testwin.document.open ();
Testwin.document.write (temp);
Testwin.document.close (); function about () {alert ("HTML code shows page directly")} function Help () {Openwindow=window.open ("", "Newwin", "height=220,width=
470,toolbar=no,scrollbars= "+scroll+", Menubar=no "); OpenWindow.document.write ("<body bgcolor= ' white ' text= ' black ' alink= ' Blue ' vlink= ' Blue ' link= ' Blue ' ><title > Help Information </TITLE> ") OpenWindow.document.write (" <center> you just put the code you want to display on the previous page in the input box, you can also write code, press the display key to display your page content </center><br> ") OpenWindow.document.write (" <center><a href= ' javascript:close () ' > Close this window </a></Center> ") OpenWindow.document.cloSE () self.name= "main"} </SCRIPT> <form name=script><textarea name=tester rows=8 wrap=off COLS=50>&L T;/textarea> <br><input onclick=test () Type=button value= display > <input onclick=trestart () Type=button value= purge > <input onclick=about () Type=button value= about > <input onclick
=help () Type=button value= Help > </FORM></TD></TR></TBODY></TABLE></CENTER> <CENTER> <div align=center> <CENTER> <table id=autonumber1 style= "Border-collapse:collapse" bordercolor= #111111 cellspacing=0 cellpadding=0 width=360 border=0> <TBODY> <TR> <TD> <p A Lign=left><span style= "font-size:9pt" > Copy the following code to the input box try <br><font color= #ff0033 ><BR>< html><br>
The
wants this article to help you with your JavaScript programming.