See a lot of people need, put it out, good things to share with everyone.
Copy Code code as follows:
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 Code code as follows:
[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:
Copy Code code as follows:
function RunCode (obj) {
var winname = window.open ("," _blank ",");
Winname.document.open (' text/html ', ' replace ');
Winname.opener = null
Winname.document.writeln (Obj.value);
Winname.document.close ();
}
function Copycode (obj) {
var rng = Document.body.createTextRange ();
Rng.movetoelementtext (obj);
Rng.scrollintoview ();
Rng.select ();
Rng.execcommand ("Copy");
Rng.collapse (FALSE);
}
function Savecode (obj) {
var winname = window.open (', ' _blank ', ' top=10000 ');
Winname.document.open (' text/html ', ' replace ');
Winname.document.write (Obj.value);
Winname.document.execCommand (' SaveAs ', ', ', ' code.htm ');
Winname.close ();
}