Add the function of running code to blog _ Application Skill

Source: Internet
Author: User
I saw him at the monk, and he added a code function to Z-blog, put a few days off, some afraid of this idle will be rusty, after 1.5 hours of sleep, but also to the Blog and run function, because it is modified from L-blog, so the same applies to l-blog, in addition, FBS is also l-blog modified, and you should also use the methods in this article to add the run code functionality. In addition, since the copy code and the Save code have not yet found a compatible solution for each browser, they are not added.
Example:
The steps are as follows:
1. Add the following code to the Include/common.js:
Copy Code code as follows:

function RunCode (Codeobjid) {
var Codeobj=document.getelementbyid (Codeobjid)
var Codestr=codeobj.value;
if (codestr!= "") {
var codewin=window.open (', ', ', ');
Codewin.document.open (' text/html ', ' replace ');
Codewin.opener = null
Codewin.document.write (CODESTR);
Codewin.document.close ();
}

}
2. Find Strcontent=re in include/ubbcode.asp. Replace (strcontent, "code") (replace "" with []), add the following code after this:
L-blog:
Copy Code code as follows:

Re. Pattern= "\[html\] (<br>) +"
Strcontent=re. Replace (strcontent, "html")

FBS:
Copy Code code as follows:

Re. Pattern= "\[html\] (<br/>) +"
Strcontent=re. Replace (strcontent, "html")

Find the re again. Pattern= "\[code\]" (. *?) \[\/code\], and then add the following code after the Set strmatches=nothing of the segment code:
Copy Code code as follows:

Re. Pattern= "\[html\]" (. *?) \[\/html\] "
Set Strmatches=re. Execute (strcontent)
For each strmatch in strmatches
Rndstr=int (7999 * Rnd + 2000)
Tmpstr1=strmatch.submatches (0)
Strcontent= Replace (Strcontent,strmatch.value, "<textarea rows=" "10" "" _
& "style=" "width:90%" "class=" "Input_border" "id=" "Html_" &RNDStr& "" > "_
&tmpStr1& "</textarea><br/>" _
& "<input type=" button "onclick=" RunCode (' Html_ "&RNDStr&"); "" Value= "" Run Code ""/> "_
& "[Ctrl + a All SELECT tips: You can modify some of the code, and then run]")
Next

Set strmatches=nothing
3. After the modification is complete, you can use the code "/html" to run using "HTML" (replace "" with []) to run the code function when you publish the log.

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.