找回密码
 立即注册
搜索
查看: 15828|回复: 0

在线编辑代码HTML/PHP实现单页可视化源码

[复制链接]
  • 打卡等级:暂无等级
  • 打卡总天数:212
  • 打卡月天数:6
  • 打卡总奖励:168
  • 最近打卡:2025-12-06 17:45:04
灌水成绩
14495
49
2035650
主题
帖子
积分

等级头衔

ID : 1

管理员

积分成就 威望 : 999999
贡献 : 9999
下载币 : 11109
在线时间 : 1089 小时
注册时间 : 2013-9-5
最后登录 : 2025-12-6

发表于 2025-11-26 10:46:27 | 显示全部楼层 |阅读模式 IP:广东
免责
免费领取大流量卡,每日更新蔡州手游APP源码密码加入群聊接手游搭建—``下载币--购买服务器☆长期招聘游戏测试员(无偿),有兴趣联系站长QQ58493525微信A0396C
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>在线可视化编辑- SOUJIZ.COM</title>
  6. <link rel="shortcut icon" href="favicon.png" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
  9. <script src="//cdn.bootcss.com/codemirror/5.2.0/codemirror.min.js"></script>
  10. <link rel="stylesheet" href="//cdn.bootcss.com/codemirror/5.2.0/codemirror.min.css">
  11. <script src="//cdn.bootcss.com/codemirror/5.2.0/mode/htmlmixed/htmlmixed.min.js"></script>
  12. <script src="//cdn.bootcss.com/codemirror/5.2.0/mode/css/css.min.js"></script>
  13. <script src="//cdn.bootcss.com/codemirror/5.2.0/mode/javascript/javascript.min.js"></script>
  14. <script src="//cdn.bootcss.com/codemirror/5.2.0/mode/xml/xml.min.js"></script>
  15. <script src="//cdn.bootcss.com/codemirror/5.2.0/addon/edit/closetag.min.js"></script>
  16. <script src="//cdn.bootcss.com/codemirror/5.2.0/addon/edit/closebrackets.min.js"></script>
  17. <!--[if lt IE 9]>
  18. <script src="//cdn.bootcss.com/html5shiv/r29/html5.min.js"></script>
  19. <![endif]-->
  20. </head>
  21. <body>
  22. <style>
  23. body{min-height:150px;padding-top:90px;background: #f6f6f6;}.container{width:98%;padding-right:15px;padding-left:15px;margin-right:auto;margin-left:auto}.CodeMirror{min-height:150px}#textareaCode{min-height:150px}#iframeResult{border:0!important;min-width:100px;width:100%;min-height:150px;background-color:#fff}@media screen and (max-width:768px){#textareaCode{height:300px}.CodeMirror{height:300px}#iframeResult{display: block;overflow: hidden;height:300px}.form-inline{padding:6px 0 2px 0}}.logo h1{background-image:url(https://tools.ly522.com/images/KAAG6G7ljI.png);background-repeat:no-repeat;text-indent:-9999px;width:160px;height:39px;margin-top:10px;display:block}
  24. </style>
  25. <nav class="navbar navbar-default navbar-fixed-top" style="background: #96b97d;">
  26. <div class="container">
  27. <div class="navbar-header logo">
  28. <h1> <a class="navbar-brand" target="_blank" href="https://www.soujiz.com" style="color: #ff0000;">soujiz</a></h1>
  29. </div>
  30. </div>
  31. </nav>
  32. <div class="container" >
  33. <div class="row">
  34. <div class="col-sm-12">
  35. <div class="panel panel-default">
  36. <div class="panel-heading">
  37. <form class="form-inline">
  38. <div class="row">
  39. <div class="col-xs-6">
  40. <button type="button" class="btn btn-default">源代码:</button>
  41. </div>
  42. <div class="col-xs-6 text-right">
  43. <button type="button" class="btn btn-success" onclick="submitTryit()" id="submitBTN"><span class="glyphicon glyphicon-send"></span> 点击运行</button>
  44. </div>
  45. </div>
  46. </form>
  47. </div>
  48. <div class="panel-body">
  49. <textarea class="form-control" id="textareaCode" name="textareaCode">
  50. 在线可视化编辑支持外链,支持html,php等
  51. </textarea>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="col-sm-12">
  56. <div class="panel panel-default">
  57. <div class="panel-heading"><form class="form-inline"> <button type="button" class="btn btn-default">运行结果</button></form></div>
  58. <div class="panel-body"><div id="iframewrapper"></div></div>
  59. </div>
  60. </div>
  61. </div>
  62. <footer>
  63. <div class="row">
  64. <div class="col-lg-12"><hr>

  65. </div>
  66. </div>
  67. </footer>
  68. </div>
  69. <script>
  70. var mixedMode = {
  71. name: "htmlmixed",
  72. scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
  73. mode: null},
  74. {matches: /(text|application)\/(x-)?vb(a|script)/i,
  75. mode: "vbscript"}]
  76. };
  77. var editor = CodeMirror.fromTextArea(document.getElementById("textareaCode"), {
  78. mode: mixedMode,
  79. selectionPointer: true,
  80. lineNumbers: false,
  81. matchBrackets: true,
  82. indentUnit: 4,
  83. indentWithTabs: true
  84. });
  85. window.addEventListener("resize", autodivheight);
  86. var x = 0;
  87. function autodivheight(){
  88. var winHeight=0;
  89. if (window.innerHeight) {
  90. winHeight = window.innerHeight;
  91. } else if ((document.body) && (document.body.clientHeight)) {
  92. winHeight = document.body.clientHeight;
  93. }
  94. //通过深入Document内部对body进行检测,获取浏览器窗口高度
  95. if (document.documentElement && document.documentElement.clientHeight) {
  96. winHeight = document.documentElement.clientHeight;
  97. }
  98. height = winHeight*0.3
  99. editor.setSize('100%', height);
  100. document.getElementById("iframeResult").style.height= height + "px";
  101. }
  102. function submitTryit() {
  103. var text = editor.getValue();
  104. var patternHtml = /<html[^>]*>((.|[\n\r])*)<\/html>/im
  105. var patternHead = /<head[^>]*>((.|[\n\r])*)<\/head>/im
  106. var array_matches_head = patternHead.exec(text);
  107. var patternBody = /<body[^>]*>((.|[\n\r])*)<\/body>/im;
  108. var array_matches_body = patternBody.exec(text);
  109. var basepath_flag = 0;
  110. var basepath = '';
  111. if(basepath_flag) {
  112. basepath = '<base href="//www.runoob.com/try/demo_source/" target="_blank">';
  113. }
  114. if(array_matches_head) {
  115. texttext = text.replace('<head>', '<head>' + basepath );
  116. } else if (patternHtml) {
  117. texttext = text.replace('<html>', '<head>' + basepath + '</head>');
  118. } else if (array_matches_body) {
  119. texttext = text.replace('<body>', '<body>' + basepath );
  120. } else {
  121. text = basepath + text;
  122. }
  123. var ifr = document.createElement("iframe");
  124. ifr.setAttribute("frameborder", "0");
  125. ifr.setAttribute("id", "iframeResult");
  126. document.getElementById("iframewrapper").innerHTML = "";
  127. document.getElementById("iframewrapper").appendChild(ifr);
  128. var ifrw = (ifr.contentWindow) ? ifr.contentWindow : (ifr.contentDocument.document) ? ifr.contentDocument.document : ifr.contentDocument;
  129. ifrw.document.open();
  130. ifrw.document.write(text);
  131. ifrw.document.close();
  132. autodivheight();
  133. }
  134. submitTryit();
  135. autodivheight();
  136. </script>
  137. </div></body>
  138. </html>
复制代码


免责
帖子地址打造全网最多免费游戏网站
今日来客 列表模式
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

本站已运行 ©2013-2026

QQ|Archiver|手机版|小黑屋|蔡州手游 |网站地图

GMT+8, 2025-12-7 06:24

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表