<textarea cols="70" rows="20" id="code"></textarea>
<script type="text/javascript">
<!--
function openWindow()
{
newWindow = window.open('','newWindow','height=300,width=500,scrollbars=auto');
if (newWindow != null)
{
var windowHTML= document.getElementById('code').value;
newWindow.document.write(windowHTML);
newWindow.focus();
}
}
//-->
</script>
<br /><br />
<input value='预览代码' onclick="openWindow();" type="button" />
Javascript预览代码
最新推荐文章于 2025-09-29 09:08:30 发布
本文介绍了一个简单的JavaScript函数,该函数能够从当前页面中抓取代码内容并打开一个新的浏览器窗口进行预览。此方法适用于需要快速查看或分享代码片段的场景。
1172

被折叠的 条评论
为什么被折叠?



