赣州建站资讯网

为消费者提供更优质的体验

利用JS实现在文本框输入代码可以在网页上直接运行调试

利用JS实现在文本框输入代码可以在网页上直接运行调试,代码如下:


<center>    
<table style="BORDER-COLLAPSE: collapse" bordercolor="#111111" cellspacing="0" cellpadding="0" border="0" borderlight="green">    
<tbody>    
<tr>    
<td align="middle"><span class="STYLE2"><font color="red">请在下面窗口中输入HTML代码</font></span></td>    
</tr>    
<tr>    
<td align="middle">    
<form name="script">    
<textarea name="tester" rows="8" wrap="off" cols="50"></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>    
</td>    
</tr>    
</tbody>    
</table>    
</center>
<script>    
function trestart() {    
if (script) {    
clear = confirm("确定要清除吗?", '');    
if (clear) {    
document.script.reset();    
document.script.value = "";    
}    
}    
}    
function test() {    
{    
temp = document.script.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='javascript:close()'>关闭本窗口</a></Center>")    
OpenWindow.document.close()    
self.name = "main"    
}    
</script>


注:需要jq库支持。


- END -
声明:文字图片等素材除标明原创外均来源于网络,如有侵权,请及时告知我们,我们将在最短的时间内删除!

相关推荐

微信公众平台:圆狐创意

关注圆狐创意微信公众平台浏览最新资讯

更多媒体及商务合作

QQ:295939675   或  至电:198-6662-0460