js-Running Code Widgets online

Source: Internet
Author: User
Tags blank page

Principle: window.open () method, open a new blank page, and then paste the code in the text box through the DOM operation, write to the new code page,

Re-use the function of document.write (written in before the other all deleted, and written in the HTML code can be parsed.) ) to achieve the desired effect.

Window.Open opens a new page is also a browser object, also has document.write this method;.

1 <!DOCTYPE HTML>2 <HTML>3     <!--4 [email protected]5 Time: 2017-04-076 Description: Run the code gadget online7      -8     <Head>9         <MetaCharSet= "UTF-8">Ten         <title>Run code Online</title> One         <Metaname= "Author"content= "gjf_xing.org1^"/> A         <Metaname= "Description"content= "gadget to run code online"/> -         <Metaname= "Keywords"content= "Gadget, code run, run code, open method, New page, online debug"/> -     </Head> the     <Body> -         <textareaname=""rows= "+"cols= "a"ID= "txt"></textarea> -         <BR/> -         <inputtype= "button"name=""ID= "BTN"value= "Run Code" /> +     </Body> -     <Scripttype= "Text/javascript"> + window.onload= function(){ A             varOtxt=document.getElementById ("txt"), at obtn=document.getElementById ("btn"); - Obtn.onclick= function(){ -                 varW=window.open ("About:blank","_blank"); - W.document.write (otxt.value); -             }; -         }; in     </Script> - </HTML>

js-Running Code Widgets online

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.