insertframe.html 4.4 KB

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