★JS实现HTML代码在线预览功能(代码运行/演示工具)★

JavaScript实现HTML代码预览功能,在输入框中输入或粘贴html代码,点击”显示”按钮查看即可浏览实际效果,相当的方便。转自源码爱好者,由@笑忘书 修改 

使用方法及注意事项使用前请先阅读本内容

使用时请在输入框中输入完整的html代码,具体演示效果可能因浏览器而异。注意: 浏览器需支持且开启JavaScript功能

<style type="text/css">
.html_Test_title{
font-size:1.1em;
background:#abc;
border-top:1px solid green;
border-bottom:1px solid green;
padding:5px 6px;
margin:3px 1px;
display:block;
}
.html_Test_ts{
color:green;
font-size:0.9em;
}
</style>
<script>
function trestart(){
   if (html_Test) {
   clear = confirm("确定要清除吗?",’’);
   if(clear) {
   document.html_Test.reset();
   document.html_Test.value = "";
  }
 }
} 
function test(){
  {
  temp = document.html_Test.tester.value;
  testwin= open("", "testwin","status=no,menubar=yes,toolbar=no");
  testwin.document.open();
  testwin.document.write(temp);
  testwin.document.close();
 }
}
function about(){
 alert("本功能支持在线即时预览html代码")
}
function help(){ 
 OpenWindow=window.open("", "newwin","height=220,width=470,toolbar=no,scrollbars="+scroll+",menubar=no");
 OpenWindow.document.write("<body bgcolor=’white’ text=’black’ alink=’blue’vlink=’blue’ link=’blue’><title>帮助信息</title>")
 OpenWindow.document.write("<center>你只要把你想显示的代码放到上页的输入框中,你自己也可以写代码,按显示键就能显示你的页面内容</center><br>")
 OpenWindow.document.write("<center><a href=’mailto:[email protected]’ target=’main’>写信给我</a></Center><br>")
 OpenWindow.document.write("<center><a href=’javascript:close()’>关闭本窗口</a></Center>")
 OpenWindow.document.close()
 self.name="main"
}
</script> 
<div class="html_Test">
<span class="html_Test_title">HTML代码预览</span>
<span class="html_Test_ts">请在下面输入框中输入html代码</span>
<form name="html_Test">
<textarea name="tester" wrap="off" rows="8" style="width:80%;">
</textarea>
<br>
<input onclick="test()" type="button" value="显示">   <input onclick="trestart()" type="button" value="清除">   <input onclick="about()" type="button" value="关于">   <input onclick="help()" type="button" value="帮助"> 
</form></div> 

HTML代码预览
请在下面输入框中输入html代码




暂无评论

发送评论 编辑评论


|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇