insertframe.html 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  5. <title></title>
  6. <script type="text/javascript" src="../internal.js"></script>
  7. <style type="text/css">
  8. .warp {
  9. width: 320px;
  10. height: 153px;
  11. margin-left: 5px;
  12. padding: 20px 0 0 15px;
  13. position: relative;
  14. }
  15. #url {
  16. width: 290px;
  17. margin-bottom: 2px;
  18. margin-left: -6px;
  19. margin-left: -2 px\9;
  20. *margin-left: 0;
  21. _margin-left: 0;
  22. }
  23. .format span {
  24. display: inline-block;
  25. width: 58px;
  26. text-align: center;
  27. zoom: 1;
  28. }
  29. table td {
  30. padding: 5px 0;
  31. }
  32. #align {
  33. width: 65px;
  34. height: 23px;
  35. line-height: 22px;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div class="warp">
  41. <table width="300" cellpadding="0" cellspacing="0">
  42. <tr>
  43. <td colspan="2" class="format">
  44. <span><var id="lang_input_address"></var></span>
  45. <input style="width:200px" id="url" type="text" value=""/>
  46. </td>
  47. </tr>
  48. <tr>
  49. <td colspan="2" class="format"><span><var id="lang_input_width"></var></span><input style="width:200px"
  50. type="text" id="width"/>
  51. px
  52. </td>
  53. </tr>
  54. <tr>
  55. <td colspan="2" class="format"><span><var id="lang_input_height"></var></span><input style="width:200px"
  56. type="text"
  57. id="height"/> px
  58. </td>
  59. </tr>
  60. <tr>
  61. <td><span><var id="lang_input_isScroll"></var></span><input type="checkbox" id="scroll"/></td>
  62. <td><span><var id="lang_input_frameborder"></var></span><input type="checkbox" id="frameborder"/></td>
  63. </tr>
  64. <tr>
  65. <td colspan="2"><span><var id="lang_input_alignMode"></var></span>
  66. <select id="align">
  67. <option value=""></option>
  68. <option value="left"></option>
  69. <option value="right"></option>
  70. </select>
  71. </td>
  72. </tr>
  73. </table>
  74. </div>
  75. <script type="text/javascript">
  76. var iframe = editor._iframe;
  77. if (iframe) {
  78. $G("url").value = iframe.getAttribute("src") || "";
  79. $G("width").value = iframe.getAttribute("width") || iframe.style.width.replace("px", "") || "";
  80. $G("height").value = iframe.getAttribute("height") || iframe.style.height.replace("px", "") || "";
  81. $G("scroll").checked = (iframe.getAttribute("scrolling") == "yes") ? true : false;
  82. $G("frameborder").checked = (iframe.getAttribute("frameborder") == "1") ? true : false;
  83. $G("align").value = iframe.align ? iframe.align : "";
  84. }
  85. function queding() {
  86. var url = $G("url").value.replace(/^\s*|\s*$/ig, ""),
  87. width = $G("width").value,
  88. height = $G("height").value,
  89. scroll = $G("scroll"),
  90. frameborder = $G("frameborder"),
  91. float = $G("align").value,
  92. newIframe = editor.document.createElement("iframe"),
  93. div;
  94. if (!url) {
  95. alert(lang.enterAddress);
  96. return false;
  97. }
  98. newIframe.setAttribute("src", /http:\/\/|https:\/\//ig.test(url) ? url : "http://" + url);
  99. /^[1-9]+[.]?\d*$/g.test(width) ? newIframe.setAttribute("width", width) : "";
  100. /^[1-9]+[.]?\d*$/g.test(height) ? newIframe.setAttribute("height", height) : "";
  101. scroll.checked ? newIframe.setAttribute("scrolling", "yes") : newIframe.setAttribute("scrolling", "no");
  102. frameborder.checked ? newIframe.setAttribute("frameborder", "1", 0) : newIframe.setAttribute("frameborder", "0", 0);
  103. float ? newIframe.setAttribute("align", float) : newIframe.setAttribute("align", "");
  104. if (iframe) {
  105. iframe.parentNode.insertBefore(newIframe, iframe);
  106. domUtils.remove(iframe);
  107. } else {
  108. div = editor.document.createElement("div");
  109. div.appendChild(newIframe);
  110. editor.execCommand("inserthtml", div.innerHTML);
  111. }
  112. editor._iframe = null;
  113. dialog.close();
  114. }
  115. dialog.onok = queding;
  116. $G("url").onkeydown = function (evt) {
  117. evt = evt || event;
  118. if (evt.keyCode == 13) {
  119. queding();
  120. }
  121. };
  122. $focus($G("url"));
  123. </script>
  124. </body>
  125. </html>