Custom HTML code runtime box

Source: Internet
Author: User

Custom HTML code runtime box


To set the HTML runtime box, prepare the following materials:

1. textarea
<Textarea style = "width: 450; Height: 300" id = "thecode" Title = "double-click the Running code" ondblclick = "runcode ('thecode '); "> put the running HTML code here. </Textarea> <br/> <input onclick = "runcode ('thecode ') "value =" run code "type =" button "> <input onclick =" docopy ('thecode ') "value =" Copy code "type =" button "> <input onclick =" dosave ('thecode', 'test ') "value =" Save code "type =" button ">


2. Three buttons
<SCRIPT type = "text/JavaScript"> // run the code function runcode (OBJ) {var winname = Window. open (''," _ blank ",''); var content = document. getelementbyid (OBJ ). value; winname.doc ument. open ('text/html ', 'replace'); winname. opener = NULL winname.doc ument. writeln (content); winname.doc ument. close () ;}// copy the code function docopy (OBJ) {var codeobj = document. getelementbyid (OBJ); clipboardData. setdata ('text', codeobj. innertext); alert ('copied Code');} // save as file function dosave (OBJ, filename) {var win = Window. open ('', '_ blank', 'top = 10000 '); var code = document. getelementbyid (OBJ ). innertext; win. opener = NULL; win.doc ument. write (CODE); win.document.exe ccommand ('saveas', true, filename); win. close () ;}</SCRIPT>


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: 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.