怎么在HTML编辑器中添加代码预览功能
发布网友
发布时间:2022-04-23 10:33
我来回答
共1个回答
热心网友
时间:2023-10-11 13:25
<SCRIPT>
function runEx(){
var winEx2 = window.open("", "winEx2",
"width=500,height=300,status=yes,menubar=no,scrollbars=yes,resizable=yes");
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.asdf.innerText)
win.document.execCommand('SaveAs','','a.html')
win.close();
}
</SCRIPT>
<DIV align=center>
<P>
<TEXTAREA id=asdf name=textfield rows=20 style="BACKGROUND-COLOR: black; BORDER-BOTTOM:
#999999 1px solid; BORDER-LEFT: #999999 1px solid; BORDER-RIGHT: #999999 1px solid; BORDER-
TOP: #999999 1px solid; COLOR: white; FONT-FAMILY: Verdana; WIDTH: 90%"
wrap=VIRTUAL></TEXTAREA>
<BR>
<BR>
<INPUT name=Button onclick=runEx() type=button value=运行代
码>
<INPUT name=Button onclick=asdf.select() type=button value=全选>
<INPUT name=Button
onclick="asdf.value=''" type=button value=清空>
<INPUT onclick=saveFile(); type=button
value=保存代码>
</DIV>上面是示例