js 哪里错了大神们!!!
<script type="text/javascript">function runCode() {
obj = document.getElementById("c");
if(obj.value==""){
alert("请输入要运行的代码内容");
return false;}
var winname = document.getElementById("i");
winname.open("text/html","replace");
winname.writeln(obj.value);
winname.close();
} </script>
-------------------------------------------------------------------
<textarea name="c" id="c">
<html>
<body><script type="text/javascript">function sayHello() {
alert("hello");
}sayHello.alternate = function() {
alert("hi");
}sayHello();
sayHello.alternate();
</script></body>
</html>
</textarea><div id="result">
<h2>查看结果:</h2>
<iframe name="i" id="i" src=""></iframe>
</div>Javascript
<script type="text/javascript">function runCode() {
obj = document.getElementById("c");
if(obj.value==""){
alert("请输入要运行的代码内容");
return false;}
var winname = document.getElementById("i");
winname.open("text/html","replace");
winname.writeln(obj.value);
winname.close();
} </script>
-------------------------------------------------------------------
<textarea name="c" id="c">
<html>
<body><script type="text/javascript">function sayHello() {
alert("hello");
}sayHello.alternate = function() {
alert("hi");
}sayHello();
sayHello.alternate();
</script></body>
</html>
</textarea><div id="result">
<h2>查看结果:</h2>
<iframe name="i" id="i" src=""></iframe>
</div>Javascript
解决方案 »
- '*.superclass.constructor' 为空或不是对象(报的错误)
- script标签顺序问题
- jquery cookie
- extjs 消息: 'this.config[...].sortable' 为空或不是对象.要怎么处理?
- 关于js的嵌套,有可能实现吗?高手来帮~~~~~
- 一段很简单的JavaScript,求助!
- 求javascript中两个日期的差等于多少天的功能,谢谢!
- 请教Javascript高手!!!!急!!!
- 通过event对象获取target
- JDK配置问题。求大神指教
- 脚本代码有点看不懂,求助各位大虾们!
- ExtJs file上传 无法提交至指定url,请求失败,求解
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Language" content="zh-cn" />
<link rel="stylesheet" type="text/css" href="tc.css" />
<title>w3school在线测试工具 v1.2</title>
</head>
<script type="text/javascript">function runCode() {
var obj = document.getElementById("c");
if(obj.value==""){
alert("请输入要运行的1代码内容");
return false;}
var winname = document.getElementById("i");
winname.document.open("text/html","replace");
winname.document.writeln(obj.value);
winname.document.close();
} </script><body id="editor"><div id="header">
<h1>W3School TIY</h1></div><div id="test"><form action="" method="post" target="i"><div id="butt">
<p><span><input name="button" type="button" onclick="runCode()" value="TRY IT YOURSELF"></input></span><span>(请在下面的文本框中编辑您的代码,然后单击此按钮测试结果。)</span></p>
</div><div id="code">
<h2>编辑您的代码:</h2>
<textarea name="c" id="c">
<html>
<body><script type="text/javascript">function sayHello() {
alert("hello");
}sayHello.alternate = function() {
alert("hi");
}sayHello();
sayHello.alternate();
</script></body>
</html>
</textarea>
</div><div id="result">
<h2>查看结果:</h2>
<iframe name="i" id="i" src=""></iframe>
</div></form>
</div><div id="footer">
<p>W3School提供的内容仅用于培训。我们不保证内容的正确性。通过使用本站内容随之而来的风险与本站无关。当使用本站时,代表您已接受了本站的使用条款和隐私条款。</p>
<p>版权所有,保留一切权利。未经书面许可,不得转载。W3School 简体中文版的所有内容仅供测试,对任何法律问题及风险不承担任何责任。上海赢科投资公司。
<a href="../index.html" tppabs="http://www.w3school.com.cn/index.html" title="W3School 在线教程">w3school.com.cn</a></p>
</div></body>
</html>
--------------------------------------
W3CSCHOOL 那个TRY IT 功能,JS有问题,能帮忙改下么
winname.document.open("text/html","replace");
winname.document.writeln(obj.value);
winname.document.close();
改为:var docu = winname.contentDocument || winname.document;
docu.open("text/html","replace");
docu.writeln(obj.value);
docu.close();