|
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> untitled document </title>
</Head>
<Body>
<Script type = "text/javascript">
// JavaScript Document
// Run the code
Function doRunCode (cod1 ){
Cod = document. getElementById (cod1)
Var code = cod. value;
If (code! = ""){
Var newwin = window. open ('','','');
Newwin. opener = null
Newwin.doc ument. write (code );
Newwin.doc ument. close ();
}
}
// Copy the code
Function doCopyCode (ID ){
If (document. all ){
TextRange = document. getElementById (ID). createTextRange ();
TextRange.exe cCommand ("Copy ");
}
Else {
// Alert ("this function is only valid on IE ");
CopyToClipboard (document. getElementById (ID). value );
}
}
// Save as code
Function doSaveCode (cod1 ){
Cod = document. getElementById (cod1)
Var code = cod. value;
If (code! = ""){
Var winname = window. open ('', '_ blank', 'top = 10000 ');
Winname.doc ument. open ('text/html ', 'replace ');
Winname.doc ument. write (code );
Winname.document.execcommand('saveas', '', 'code.htm ');
Winname. close ();
}
}
Function copyToClipboard (txt ){
If (window. clipboardData ){
Window. clipboardData. clearData ();
Window. clipboardData. setData ("Text", txt );
} Else if (navigator. userAgent. indexOf ("Opera ")! =-1 ){
Window. location = txt;
} Else if (window. netscape ){
Try {
Netscape. security. PrivilegeManager. enablePrivilege ("UniversalXPConnect ");
} Catch (e ){
Alert ("rejected by the browser! N enter 'about: config' in the address bar of the browser, press ENTER n, and set 'signed. applets. codebase_principal_support 'to 'true '");
}
Var clip = Components. classes ['@ mozilla.org/widget/clipboard=1'mirror.createinstance (Components. interfaces. nsIClipboard );
If (! Clip)
Return;
Var trans = Components. classes ['@ mozilla.org/widget/transferable00001').createinstance (Components. interfaces. nsITransferable );
If (! Trans)
Return;
Trans. addDataFlavor ('text/unicode ');
Var str = new Object ();
Var len = new Object ();
Var str = Components. classes ["@ mozilla.org/supports-string1_1"]. createInstance (Components. interfaces. nsISupportsString );
Var copytext = txt;
Str. data = copytext;
Trans. setTransferData ("text/unicode", str, copytext. length * 2 );
Var clipid = Components. interfaces. nsIClipboard;
If (! Clip)
Return false;
Clip. setData (trans, null, clipid. kGlobalClipboard );
}
}
</Script>
<Div class = "UBBContainer">
<Div class = "UBBTitle"> The following is the program code </div>
<Div class = "UBBContent">
<Textarea class = "UBBText" id = "CodeText62670" rows = "8"> here is the html code to be run. </textarea>
<Br>
<Input type = "button" value = "Running code" onclick = "doRunCode ('codetext62670')">
<Input type = "button" value = "Copy code" onclick = "doCopyCode ('codetext62670')">
<Input type = "button" value = "other code" onclick = "doSaveCode ('codetext62670')">
<Br>
[Ctrl + A select all tips: you can modify some code and then press run] </div>
</Div>
</Body>
</Html> |