<HTML>
<HEAD>
<title>eg</title>
<SCRIPT language=JavaScript>
function runEx(){
var winEx2 = window.open("", "winEx2",""); winEx2.document.open("text/html", "replace");
winEx2.document.write(unescape(event.srcElement.parentElement.children[0].value));
winEx2.document.close();
}
function saveFile()
{
var win=window.open('','','top=10000,left=10000');
win.document.write(document.all.junmarun.innerText)
win.document.execCommand('SaveAs','','copy.htm')
win.close();
}
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args+".location='"+args[i+1]+"'");
}
function JM_cc(ob){
var obj=MM_findObj(ob); if (obj) {
obj.select();js=obj.createTextRange();js.execCommand("Copy");}
}
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}
//-->
</SCRIPT>
</HEAD>
<BODY bgcolor="#FFFFFF" leftMargin=0 topMargin=0 MARGINWIDTH="0" MARGINHEIGHT="0">
<TABLE width="770" height="1" border=0 align="center" cellpadding="0" cellSpacing=0 style="border-collapse: collapse">
<FORM action="" method=post name=form1>
<TR>
<TD height="1" align="center"> <strong>代码演示</strong> </TD>
</TR>
<tr>
<TD height=1 width="140"><SPACER type="block" width="1"></spacer> </TD>
</tr>
<TR>
<TD height="1">
<p align="center">
<TEXTAREA id=junmarun name=textfield rows=25 cols="91"></TEXTAREA>
<BR>
<INPUT name=Button onclick=runEx() type=button value=预览效果 style="background-color: #FFFFFF">
<INPUT name=Button onclick=junmarun.select() type=button value=全选代码 style="background-color: #FFFFFF">
<INPUT name=Button onclick="junmarun.value=''" type=button value=清空代码 style="background-color: #FFFFFF">
<INPUT name=Button onclick="JM_cc('textfield')" type=button value=复制代码 style="background-color: #FFFFFF">
<INPUT onclick=saveFile(); type=button value=保存代码 style="background-color: #FFFFFF">
<INPUT onclick="javascript:self.close()" type=button value=关闭窗口 style="background-color: #FFFFFF"></DIV> </TD></TR>
</form>
</TABLE>
</BODY>
</HTML>
用于参考或试验