Let your ewbeditor also be able to run code _ Application Tips

Source: Internet
Author: User
See a lot of blogs that can support the direct running of JavaScript code demo. Unfortunately Ewebeditor from 3.6 to 4.0, 4.6 did not say so. Take a look at the code today; To think about it is actually very simple to achieve. The experiment was very successful, and share with you below, so that your ewbeditor can also run JavaScript code suitable for Ewebeditor 3.8,4.0 4.4 4.6 can be.

First we need to run the code of the JS file is the JavaScript code, you can make him into a JS file can also be directly placed on the page of the call

For example, my display.asp file. Because this is the final display of the content of the page, the user is looking at the time is this page, the running code is definitely on this page, so we put the code into this page
Between <script Language=javascript type=text/javascript></script>:

The specific code is as follows:

function RunEx (COD1) {
Cod=document.getelementbyid (COD1)
var Code=cod.value;
if (code!= "") {
var newwin=window.open (', ', ', ');
Newwin.opener = null
Newwin.document.write (code);
Newwin.document.close ();
}
}


By adding this function to the <script language=javascript type=text/javascript></javascript>, we're going to build the input box and run button for our running code.

Use a text field box if you can't enter directly, you can switch to the code state to enter the following code directly:
<textarea style= "WIDTH:579PX; height:42px "cols=23></textarea>
The ewbeditor is called the Insert input area.

After the insertion is complete, you need to change it (switch to code State), assign an ID value to it (as long as possible to distinguish between the other elements), when completed:
<textarea id= "2020" style= "WIDTH:579PX; height:42px "cols=23></textarea>

Switch to design state enter the code to run in the text field.

Add a Run button below (Insert button in Ewebeditor), and if you can't join, switch to code state to enter the following code in your code:
<button style= "WIDTH:52PX; HEIGHT:24PX "> Run code </BUTTON>

Then add an event to the button: onclick= "RunEx (' 2020 ')"

The value here must be consistent with the value of the ID of the Given Text field box. The following button code is complete:
<button onclick= "RunEx (' 2020 ')" style= "WIDTH:52PX; HEIGHT:24PX "> Run code </BUTTON>

The settings need to be switched to the code state to complete.

<textarea id= "202320" style= "WIDTH:579PX; height:42px "cols=23></textarea>
<button onclick= "RunEx (' 202320 ')" style= "WIDTH:62PX; HEIGHT:24PX "> Run code </BUTTON>

You can copy the above code and then switch to the code state to find a place to paste up, back to edit the state can be used directly, need more than a few words, please change the ID value OH.

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.