教程集 www.jiaochengji.com
教程集 >  脚本编程  >  javascript  >  正文 在线运行,复制,另存为的js代码

在线运行,复制,另存为的js代码

发布时间:2017-03-25   编辑:jiaochengji.com
教程集为您提供在线运行,复制,另存为的js代码等资源,欢迎您收藏本站,我们将为您提供最新的在线运行,复制,另存为的js代码资源
提示:您可以先修改部分代码再运行

<textarea name="runcool" rows="28" cols="75" > <html xmlns="http://www.jiaochengji.com/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>在线运行,复制,另存为的js代码</title> <style type="text/css"> body,td,th {font-size: 12px;} </style> </head> <body> <script language="javascript"> var userAgent = navigator.userAgent.toLowerCase(); var is_opera = userAgent.indexOf('opera') != -1 && opera.version(); var is_saf = userAgent.indexOf('applewebkit') != -1 || navigator.vendor == 'Apple Computer, Inc.'; var is_webtv = userAgent.indexOf('webtv') != -1; var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera && !is_saf && !is_webtv) && userAgent.substr(userAgent.indexOf('msie') 5, 3); //运行代码 function runCode(obj) { var winname = window.open('', "_blank", ''); winname.document.open('text/html', 'replace'); winname.opener = null; // 防止代码对论谈页面修改 winname.document.write(obj.value); winname.document.close(); } //另存代码 function saveCode(obj) { var winname = window.open('', '_blank', 'top=10000'); winname.document.open('text/html', 'replace'); winname.document.write(obj.value); winname.document.execCommand('saveas','','HtmlCode.html'); winname.close(); } //复制代码 function copycode(obj) { if(is_ie && obj.style.display != 'none') { var rng = document.body.createTextRange(); rng.moveToElementText(obj); rng.scrollIntoView(); rng.select(); rng.execCommand("Copy"); rng.collapse(false); } } //随机函数 function RndNum(n) { var rnd=""; for(var i=0;i<n;i ) rnd =Math.floor(Math.random()*10); return rnd; } 提示:您可以先修改部分代码再运行 </body> </html></textarea>
提示:您可以先修改部分代码再运行

您可能感兴趣的文章:
在线运行,复制,另存为的js代码
超简单js在线文本编辑器
js 调用IE的“另存为”特效代码
兼容多浏览器js给元素添加样式css
鼠标经过显示二级菜单js特效
js 下拉折叠菜单代码
js 获取div内容再修改div内容
原生态的js计算器代码
js div 可拖动层代码
Go 并发编程的思考

[关闭]
~ ~