JavaScript run code box code
Author:Eve Cole
Update Time:2009-06-11 16:32:29
program code
<script language="JavaScript" type="text/JavaScript">
//Run the text field code
function runEx(cod1) {
cod=document.all(cod1)
var code=cod.value;
if (code!=""){
var newwin=window.open('','',''); //Open a window and assign it to variable newwin.
newwin.opener = null // Prevent code from modifying the discussion page
newwin.document.write(code); //Write code into this open window, thus realizing the function of running code.
newwin.document.close();
}
}
</script>
<textarea name="textarea" cols="60" rows="10" id="rn01">Add HTML code</textarea>
<br />
<INPUT onclick="runEx('rn01')" type="button" value="Run code" style="cursor:hand"> [Ctrl+A All selection tips: You can modify part of the code first, and then press Run]