insertframe.html 4.1 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. <script type="text/javascript" src="../internal.js"></script>
  7. <style type="text/css">
  8. * {color: #838383}
  9. body {font-size: 12px;width: 320px;height: 153px;overflow: hidden; margin: 0;padding: 0; }
  10. .warp {padding: 20px 0 0 15px;height: 100%;position: relative;}
  11. #url {width: 290px; margin-bottom: 2px}
  12. table td{padding:5px 0;}
  13. </style>
  14. </head>
  15. <body>
  16. <div class="warp">
  17. <table width="300" cellpadding="0" cellspacing="0">
  18. <tr>
  19. <td colspan="2">
  20. <span>地址:</span><input style="width:200px" id="url" type="text" value=""/>
  21. </td>
  22. </tr>
  23. <tr>
  24. <td colspan="2"><span>宽度:</span><input style="width:200px" type="text" id="width"/> px</td>
  25. </tr>
  26. <tr>
  27. <td colspan="2"><span>高度:</span><input style="width:200px" type="text" id="height"/> px</td>
  28. </tr>
  29. <tr>
  30. <td><span>允许滚动条:</span><input type="checkbox" id="scroll"/> </td>
  31. <td><span>显示框架边框:</span><input type="checkbox" id="frameborder"/> </td>
  32. </tr>
  33. <tr>
  34. <td colspan="2"><span>对齐方式:</span>
  35. <select id="align">
  36. <option value="">默认</option>
  37. <option value="left">左对齐</option>
  38. <option value="right">右对齐</option>
  39. <option value="middle">居中</option>
  40. </select>
  41. </td>
  42. </tr>
  43. </table>
  44. </div>
  45. <script type="text/javascript">
  46. var iframe = editor._iframe;
  47. if(iframe){
  48. $G("url").value = iframe.getAttribute("src")||"";
  49. $G("width").value = iframe.getAttribute("width")||iframe.style.width.replace("px","")||"";
  50. $G("height").value = iframe.getAttribute("height") || iframe.style.height.replace("px","") ||"";
  51. $G("scroll").checked = (iframe.getAttribute("scrolling") == "yes") ? true : false;
  52. $G("frameborder").checked = (iframe.getAttribute("frameborder") == "1") ? true : false;
  53. $G("align").value = iframe.align ? iframe.align : "";
  54. }
  55. function queding(){
  56. var url = $G("url").value.replace(/^\s*|\s*$/ig,""),
  57. width = $G("width").value,
  58. height = $G("height").value,
  59. scroll = $G("scroll"),
  60. frameborder = $G("frameborder"),
  61. float = $G("align").value,
  62. newIframe = editor.document.createElement("iframe"),
  63. div;
  64. if(!url){
  65. alert("请输入地址!");
  66. return false;
  67. }
  68. newIframe.setAttribute("src",/http:\/\/|https:\/\//ig.test(url) ? url : "http://"+url);
  69. /^[1-9]+[.]?\d*$/g.test( width ) ? newIframe.setAttribute("width",width) : "";
  70. /^[1-9]+[.]?\d*$/g.test( height ) ? newIframe.setAttribute("height",height) : "";
  71. scroll.checked ? newIframe.setAttribute("scrolling","yes") : newIframe.setAttribute("scrolling","no");
  72. frameborder.checked ? newIframe.setAttribute("frameborder","1",0) : newIframe.setAttribute("frameborder","0",0);
  73. float ? newIframe.setAttribute("align",float) : newIframe.setAttribute("align","");
  74. if(iframe){
  75. iframe.parentNode.insertBefore(newIframe,iframe);
  76. domUtils.remove(iframe);
  77. }else{
  78. div = editor.document.createElement("div");
  79. div.appendChild(newIframe);
  80. editor.execCommand("inserthtml",div.innerHTML);
  81. }
  82. editor._iframe = null;
  83. dialog.close();
  84. }
  85. dialog.onok = queding;
  86. $G("url").onkeydown = function(evt){
  87. evt = evt || event;
  88. if(evt.keyCode == 13){
  89. queding();
  90. }
  91. };
  92. $focus($G( "url" ));
  93. </script>
  94. </body>
  95. </html>