ASP implementation of the Code "run Code" "Copy Code" "Save Code" function Source _ Application techniques
Source: Internet
Author: User
Function Content_code (STR)
Dim Ary_string,i,n,n_pos
Ary_string=split (STR, "[Code]")
N=ubound (ary_string)
If N<1 Then
Content_code=str
Exit function
End If
For I=1 to N
N_pos=instr (Ary_string (i), "[/code]")
If N_pos>0 Then
Ary_string (i) = "<br/><textarea class=gocode id=runcode" &i& "Name=runcode" &i& ">" & Server. HTMLEncode (Left (ary_string (i), n_pos-1)) & "</textarea><br/><input Type=button, Class=input-code Value= Run code onclick=runcode (RunCode "&i&") ><input type=button class=input-code value= Replication Code onclick= Copycode (RunCode "&i&") ><input Type=button class=input-code value= Save Code Onclick=savecode (RunCode "& i& ") ><span class=code-tishi> Hint: You can modify some of the code before running </span><br/>" & _
Right (ary_string (i), Len (ary_string (i))-n_pos-6)
Else
Ary_string (i) = "[Code]" & Ary_string (i)
End If
Next
Content_code=join (Ary_string, "")
End Function
The use method is also very simple:
You need to use the "Run Code" feature when you publish an article, mainly plus
[Code] [/code]
Like what:
[Copy this Code] CODE:
[Code]
<script type= "Text/javascript" >
Alert ("Simple Bar");
</script>
[/code]
It should be noted that the page to be displayed is to enter the following javascript:
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.