insertframe.html 4.6KB

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