| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title>插入框架</title>
- <script type="text/javascript" src="../internal.js"></script>
- <style type="text/css">
- * {color: #838383}
- body {font-size: 12px;width: 320px;height: 153px;overflow: hidden; margin: 0;padding: 0; }
- .warp {padding: 20px 0 0 15px;height: 100%;position: relative;}
- #url {width: 290px; margin-bottom: 2px}
- table td{padding:5px 0;}
- </style>
- </head>
- <body>
- <div class="warp">
- <table width="300" cellpadding="0" cellspacing="0">
- <tr>
- <td colspan="2">
- <span>地址:</span><input style="width:200px" id="url" type="text" value=""/>
- </td>
- </tr>
- <tr>
- <td colspan="2"><span>宽度:</span><input style="width:200px" type="text" id="width"/> px</td>
- </tr>
- <tr>
- <td colspan="2"><span>高度:</span><input style="width:200px" type="text" id="height"/> px</td>
- </tr>
- <tr>
- <td><span>允许滚动条:</span><input type="checkbox" id="scroll"/> </td>
- <td><span>显示框架边框:</span><input type="checkbox" id="frameborder"/> </td>
- </tr>
- <tr>
- <td colspan="2"><span>对齐方式:</span>
- <select id="align">
- <option value="">默认</option>
- <option value="left">左对齐</option>
- <option value="right">右对齐</option>
- <option value="middle">居中</option>
- </select>
- </td>
- </tr>
- </table>
- </div>
- <script type="text/javascript">
- var iframe = editor._iframe;
- if(iframe){
- $G("url").value = iframe.getAttribute("src")||"";
- $G("width").value = iframe.getAttribute("width")||iframe.style.width.replace("px","")||"";
- $G("height").value = iframe.getAttribute("height") || iframe.style.height.replace("px","") ||"";
- $G("scroll").checked = (iframe.getAttribute("scrolling") == "yes") ? true : false;
- $G("frameborder").checked = (iframe.getAttribute("frameborder") == "1") ? true : false;
- $G("align").value = iframe.align ? iframe.align : "";
- }
- function queding(){
- var url = $G("url").value.replace(/^\s*|\s*$/ig,""),
- width = $G("width").value,
- height = $G("height").value,
- scroll = $G("scroll"),
- frameborder = $G("frameborder"),
- float = $G("align").value,
- newIframe = editor.document.createElement("iframe"),
- div;
- if(!url){
- alert("请输入地址!");
- return false;
- }
- newIframe.setAttribute("src",/http:\/\/|https:\/\//ig.test(url) ? url : "http://"+url);
- /^[1-9]+[.]?\d*$/g.test( width ) ? newIframe.setAttribute("width",width) : "";
- /^[1-9]+[.]?\d*$/g.test( height ) ? newIframe.setAttribute("height",height) : "";
- scroll.checked ? newIframe.setAttribute("scrolling","yes") : newIframe.setAttribute("scrolling","no");
- frameborder.checked ? newIframe.setAttribute("frameborder","1",0) : newIframe.setAttribute("frameborder","0",0);
- float ? newIframe.setAttribute("align",float) : newIframe.setAttribute("align","");
- if(iframe){
- iframe.parentNode.insertBefore(newIframe,iframe);
- domUtils.remove(iframe);
- }else{
- div = editor.document.createElement("div");
- div.appendChild(newIframe);
- editor.execCommand("inserthtml",div.innerHTML);
- }
- editor._iframe = null;
- dialog.close();
- }
- dialog.onok = queding;
- $G("url").onkeydown = function(evt){
- evt = evt || event;
- if(evt.keyCode == 13){
- queding();
- }
- };
- $focus($G( "url" ));
- </script>
- </body>
- </html>
|