+ -
当前位置:首页 → 问答吧 → 这是哪里有问题,为什么总是报错?

这是哪里有问题,为什么总是报错?

时间:2010-05-07

来源:互联网

复制内容到剪贴板
代码:
          <textarea cols="95" rows="15" name="runcode0" >运行的代码</textarea>
            <input type="button" value="运行代码" onclick="runCode(runcode0)" />
            <input type="button" value="复制代码" onclick="copycode(runcode0)" />
            <input type="button" value="另存代码" onclick="saveCode(runcode0)" /> &nbsp;提示:您可以先修改部分代码再运行
        <script language="javascript">
script>
function runCode(obj){ //定义一个运行代码的函数,
   var code=getByid("runcode"+obj).value;//即要运行的代码。
   var newwin=window.open('','',''); //打开一个窗口并赋给变量newwin。
   newwin.opener = null // 防止代码对论谈页面修改
   newwin.document.write(code); //向这个打开的窗口中写入代码code,这样就实现了运行代码功能。
   newwin.document.close();
}
//复制代码
function doCopy(obj) {
if (document.all){
   textRange = getByid("runcode"+obj).createTextRange();
   textRange.execCommand("Copy");
   alert("代码已经复制到剪切板");
}else{
   alert("此功能只能在IE上有效nn请在文本域中用Ctrl+A选择再复制")
}
}
//另存代码
function saveCode(obj) {
        var winname = window.open('','','width=0,height=0,top=200,left=200px');
        winname.document.open('text/html', 'replace');
        winname.document.write(obj.value);
        winname.document.execCommand('saveas','','CSS打造经典鼠标触发显示选项.html');
        winname.close();
}
</script>
QQ截图未命名.png (907 Bytes)
2010-5-7 15:35

作者: Anthonys   发布时间: 2010-05-07


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> </head> <body> <textarea cols="95" rows="15" name="runcode0" id="runcode0" >运行的代码</textarea> <input type="button" value="运行代码" onclick="runCode(0)" /> <input type="button" value="复制代码" onclick="doCopy(0)" /> <input type="button" value="另存代码" onclick="saveCode(0)" /> &nbsp;提示:您可以先修改部分代码再运行 <script language="javascript"> function runCode(obj){ //定义一个运行代码的函数, var code=document.getElementById("runcode"+obj).value;//即要运行的代码。 var newwin=window.open('','',''); //打开一个窗口并赋给变量newwin。 newwin.opener = null // 防止代码对论谈页面修改 newwin.document.write(code); //向这个打开的窗口中写入代码code,这样就实现了运行代码功能。 newwin.document.close(); } //复制代码 function doCopy(obj) { if (document.all){ textRange = document.getElementById("runcode"+obj).createTextRange(); textRange.execCommand("Copy"); alert("代码已经复制到剪切板"); }else{ alert("此功能只能在IE上有效nn请在文本域中用Ctrl+A选择再复制") } } //另存代码 function saveCode(obj) { var winname = window.open('','','width=0,height=0,top=200,left=200px'); winname.document.open('text/html', 'replace'); winname.document.write(obj.value); winname.document.execCommand('saveas','','CSS打造经典鼠标触发显示选项.html'); winname.close(); } </script> </body> </html>
 提示:您可以先修改部分代码再运行

作者: qxq864298   发布时间: 2010-05-07

哦,耶! 可以了,谢谢,是没看仔细

作者: Anthonys   发布时间: 2010-05-07