In most forums or blogs, you can see a piece of code in the author's or comments and perform online testing. the code for implementing this function is as follows: [javascript] & lt ;! DOCTYPEhtmlPUBLIC & quot;-// W3C // DTDXHTML1.0Transitional // EN & quot ;...
In most forums or blogs, you can see a piece of code in the author's or comments and perform online testing.
The code for implementing this function is as follows:
[Javascript]
Run Code
Script
Function runCode (textId ){
Var code = document. getElementById (textId). value;
Var newWindow = window. open ();
NewWindow. opener = null; // do not perform any operation on the Window that creates the Window (newWindow.
Newmediaworkflow Doc ument. write (code );
Newclientdoc ument. close (); // close the file stream opened by the open () method.
};
Function copyCode (textId ){
If (window. clipboardData) {// judge the browser. Currently, only Internet Explorer is supported.
Var otext = document. getElementById (textId). value;
Window. clipboardData. setData ('text', otext );
Alert ('copied successfully! ');
} Else {
Alert ("your browser does not support this function. Please manually select text to copy it! ");
}
};
Script
<B> Hi, This is my website! </B> </textarea "> http://maplejan.com/"> website! </B>
Run Code
Script
Function runCode (textId ){
Var code = document. getElementById (textId). value;
Var newWindow = window. open ();
NewWindow. opener = null; // do not perform any operation on the Window that creates the Window (newWindow.
Newmediaworkflow Doc ument. write (code );
Newclientdoc ument. close (); // close the file stream opened by the open () method.
};
Function copyCode (textId ){
If (window. clipboardData) {// judge the browser. Currently, only Internet Explorer is supported.
Var otext = document. getElementById (textId). value;
Window. clipboardData. setData ('text', otext );
Alert ('copied successfully! ');
} Else {
Alert ("your browser does not support this function. Please manually select text to copy it! ");
}
};
Script
<B> Hi, This is my website! </B>
Demo
Excerpt from jian sheng's code Memorandum