在线运行Javascript,Jquery,HTML,CSS代码
<!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> <title>在线运行Javascript,Jquery,HTML,CSS代码</title> <script type="text/javascript"> var userAgent = navigator.userAgent.toLowerCase(); var is_webtv = userAgent.indexOf('webtv') != -1; var is_kon = userAgent.indexOf('konqueror') != -1; var is_mac = userAgent.indexOf('mac') != -1; var is_saf = userAgent.indexOf('applewebkit') != -1 || navigator.vendor == 'Apple Computer, Inc.'; var is_opera = userAgent.indexOf('opera') != -1 && opera.version(); var is_moz = (navigator.product == 'Gecko' && !is_saf) && userAgent.substr(userAgent.indexOf('firefox') + 8, 3); var is_ns = userAgent.indexOf('compatible') == -1 && userAgent.indexOf('mozilla') != -1 && !is_opera && !is_webtv && !is_saf; var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera && !is_saf && !is_webtv) && userAgent.substr(userAgent.indexOf('msie') + 5, 3); function $(id) { return document.getElementById(id); } 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 runCode(obj) { var winname = window.open('', "_blank", ''); winname.document.open('text/html', 'replace'); 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.writeln(obj.value); winname.document.execCommand('saveas','','code.htm'); winname.close(); } </script> </head> <body onkeydown="if(event.keyCode==27) return false;"> <span>请在下面输入 HTML 代码段</span><p> <textarea id="code0" rows="30" cols="160"> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>在线运行</title> <style> </style> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> <head> <body> <div>这儿为页面内容</div> <script type="text/javascript"> $(document).ready(function(e) { //这儿加载页面加载完成后执行的代码 }); </script> </body> </html> </textarea><p> <input type="button" value="运行代码" onclick="runCode($('code0'))"> <input type="button" value="复制代码" onclick="copyCode($('code0'))"> <input type="button" value="另存代码" onclick="saveCode($('code0'))"> 提示:您可以修改上面部分代码后再重新运行 </body></html>
作者:Bober Song
出处:http://bober.cnblogs.com/
CARE健康网: http://www.aicareyou.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://bober.cnblogs.com/
CARE健康网: http://www.aicareyou.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。