insertframe.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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: -2px\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"><span><var
  44. id="lang_input_address"></var></span> <input style="width: 200px"
  45. id="url" type="text" value="" /></td>
  46. </tr>
  47. <tr>
  48. <td colspan="2" class="format"><span><var
  49. id="lang_input_width"></var></span><input style="width: 200px"
  50. type="text" id="width" /> px</td>
  51. </tr>
  52. <tr>
  53. <td colspan="2" class="format"><span><var
  54. id="lang_input_height"></var></span><input style="width: 200px"
  55. type="text" id="height" /> px</td>
  56. </tr>
  57. <tr>
  58. <td><span><var id="lang_input_isScroll"></var></span><input
  59. type="checkbox" id="scroll" /></td>
  60. <td><span><var id="lang_input_frameborder"></var></span><input
  61. type="checkbox" id="frameborder" /></td>
  62. </tr>
  63. <tr>
  64. <td colspan="2"><span><var id="lang_input_alignMode"></var></span>
  65. <select id="align">
  66. <option value=""></option>
  67. <option value="left"></option>
  68. <option value="right"></option>
  69. </select></td>
  70. </tr>
  71. </table>
  72. </div>
  73. <script type="text/javascript">
  74. var iframe = editor._iframe;
  75. if(iframe){
  76. $G("url").value = iframe.getAttribute("src")||"";
  77. $G("width").value = iframe.getAttribute("width")||iframe.style.width.replace("px","")||"";
  78. $G("height").value = iframe.getAttribute("height") || iframe.style.height.replace("px","") ||"";
  79. $G("scroll").checked = (iframe.getAttribute("scrolling") == "yes") ? true : false;
  80. $G("frameborder").checked = (iframe.getAttribute("frameborder") == "1") ? true : false;
  81. $G("align").value = iframe.align ? iframe.align : "";
  82. }
  83. function queding(){
  84. var url = $G("url").value.replace(/^\s*|\s*$/ig,""),
  85. width = $G("width").value,
  86. height = $G("height").value,
  87. scroll = $G("scroll"),
  88. frameborder = $G("frameborder"),
  89. float = $G("align").value,
  90. newIframe = editor.document.createElement("iframe"),
  91. div;
  92. if(!url){
  93. alert(lang.enterAddress);
  94. return false;
  95. }
  96. newIframe.setAttribute("src",/http:\/\/|https:\/\//ig.test(url) ? url : "http://"+url);
  97. /^[1-9]+[.]?\d*$/g.test( width ) ? newIframe.setAttribute("width",width) : "";
  98. /^[1-9]+[.]?\d*$/g.test( height ) ? newIframe.setAttribute("height",height) : "";
  99. scroll.checked ? newIframe.setAttribute("scrolling","yes") : newIframe.setAttribute("scrolling","no");
  100. frameborder.checked ? newIframe.setAttribute("frameborder","1",0) : newIframe.setAttribute("frameborder","0",0);
  101. float ? newIframe.setAttribute("align",float) : newIframe.setAttribute("align","");
  102. if(iframe){
  103. iframe.parentNode.insertBefore(newIframe,iframe);
  104. domUtils.remove(iframe);
  105. }else{
  106. div = editor.document.createElement("div");
  107. div.appendChild(newIframe);
  108. editor.execCommand("inserthtml",div.innerHTML);
  109. }
  110. editor._iframe = null;
  111. dialog.close();
  112. }
  113. dialog.onok = queding;
  114. $G("url").onkeydown = function(evt){
  115. evt = evt || event;
  116. if(evt.keyCode == 13){
  117. queding();
  118. }
  119. };
  120. $focus($G( "url" ));
  121. </script>
  122. </body>
  123. </html>