📄 iframe.js
字号:
/** * <p>iframe.js - create a dialog</p> * <p>apnana javascript client library</p> * <p>DOM ID used: APIframe-* APIframe_*</p> * @author Li Shaopeng * @version 0.3 2007-02-05 */
/** * define and write CSS */if(APIFRAME_STYLE==undefined){ var APIFRAME_STYLE = '<style>\ .APIframe-border{border-top:1px solid #e4e0d7;border-left:1px solid #e4e0d7;border-right:1px solid #555555;border-bottom:1px solid #555555;}\ .APIframe-title td{height:23px;background-color:#3588e7;font-weight:bold;color:white;padding-top:4px}\ .APIframe-back{background-color:#e8e8e8;}\ </style>'}document.write(APIFRAME_STYLE);APIFRAME_STYLE = null;/** * Global object APIframe */var APIframe={};/** * iframe dialog */APIframe.iframehtml = '\<table class="APIframe-border" border="0" cellspacing="0" cellpadding="0"><tr><td onmouseover="APIframe.nframe=\'frmid\'">\ <table border="0" cellspacing="0" id="tw_frmid" cellpadding="0" width="${width}px">\ <tr class="APIframe-title">\ <td align="left" onmouseover="this.style.cursor=\'move\'" onmousedown="APIframe.startmove(event)" width="99%"> <b>${title}</b></td>\ <td align="right" width="10px"><div style="font-size:14px;font-family:Nina;font-weight:bold;margin-right:3px;" onclick="APIframe.destroy()" onmouseover="this.style.cursor=\'pointer\'">×</div></td>\ </tr>\ <tr class="APIframe-back">\ <td colspan="2" style="border-top:1px solid #555555" align="center" id="tb_frmid" valign="top" style="height:theheightpx;"><div style="border-top:1px solid white;width:100%"><div id="dv_frmid" style="padding-top:50px;font-size:14px"><img src="/r/simple/img/loading_icon.gif"> 装载中,请稍后...</div><iframe onclick="alert(1)" style="display:none" onload="APIframe.showp(\'frmid\')" name="frmid" id="frmid" frameborder=0 width="100%" style="height:theheightpx;"></iframe></div></td>\ </tr>\ <table>\</td></tr></table><form id="frm-frmid" method="post" target="frmid" action="purl"></form>';/** * APIframe stack, [bg-iframe, APIframe-div] */APIframe.stack = {};APIframe.height = {};APIframe.width = {};APIframe.nframe = '';/** * * @param {Object} tit - title * @param {Object} src - src url * @param {Object} height - height * @param {Object} width - width */APIframe.open = function(tit,src,width,height){ //APIframe.gc(); var oframe = document.createElement('span'); var a1 = APIframe.iframehtml.replace("${title}",tit); var a2 = a1.replace("${width}",width); var a3 = a2.replaceAll("theheight",height); b = 'fm-'+$t(); var a4 = a3.replaceAll('frmid',b); var a5 = a4.replace("purl",src); oframe.innerHTML = a5; document.body.appendChild(oframe); APIframe.stack[b] = oframe; APIframe.width[b] = parseInt(width)+2; APIframe.height[b] = parseInt(height)+18; APIframe.middle(oframe); oframe = null; //$(b).src = src; $("frm-"+b).submit(); APIframe.nframe = b;}APIframe.setheight = function(h){ $('tb_'+APIframe.nframe).style.height = h+'px';}APIframe.setwidth = function(w){ $('tw_'+APIframe.nframe).style.width = w+'px';}APIframe.showp = function (iid){ $(iid).style.display = 'block'; $('dv_'+iid).style.display = 'none';}/** * Destroy top dialog */APIframe.destroy = function(){ $(APIframe.nframe).src=''; APIframe.stack[APIframe.nframe].style.display="none"; APDialog.destroy();}APIframe.gc = function(){ for(var prop in APIframe.stack) { if(APIframe.stack[prop].style.display=='none') { document.body.removeChild(APIframe.stack[prop]); APIframe.stack[prop] = null; APIframe.height[prop] = null; APIframe.width[prop] = null; CollectGarbage(); } }}/** * <p>make APIframe middle</p> * @param {Object} dlg - box to be fixed */APIframe.middle = function(dlg){ var scrollp = $s(); dlg.style.position = 'absolute'; dlg.style.left = (document.body.clientWidth / 2) - (dlg.offsetWidth / 2) + 'px'; var sTop = scrollp.t + window.screen.availHeight/7; dlg.style.top = sTop > 0 ? sTop + 'px' : '10px'; dlg=null;}APIframe.zindex = 100;/** * <p>drag APIframe</p> * @param {Object} event */APIframe.startmove = function(event){ var oObj = APIframe.stack[APIframe.nframe]; var dr = document.createElement('span'); document.body.appendChild(dr); dr.style.position = 'absolute'; dr.style.zIndex = 9999; dr.style.left = oObj.style.left; dr.style.top = oObj.style.top; dr.innerHTML = '<table style="cursor:move;border:5px solid #cccccc" width="'+APIframe.width[APIframe.nframe]+'px" cellspacing=0 cellpadding=0><tr><td height="'+APIframe.height[APIframe.nframe]+'px"></td></tr></table>'; dr.onmousemove = mousemove; dr.onmouseup = mouseup; dr.setCapture ? dr.setCapture() : function(){}; oEvent = window.event ? window.event : event; var dragData = {x : oEvent.clientX, y : oEvent.clientY}; function mousemove(event){ var oEvent = window.event ? window.event : event; var iLeft = oEvent.clientX - dragData["x"] + parseInt(dr.style.left); var iTop = oEvent.clientY - dragData["y"] + parseInt(dr.style.top); if(iLeft<0)iLeft=0; if(iTop<0)iTop=0; dr.style.left = iLeft + 'px'; dr.style.top = iTop + 'px'; dragData = {x: oEvent.clientX, y: oEvent.clientY}; } function mouseup(event){ var oEvent = window.event ? window.event : event; dr.onmousemove = null; dr.onmouseup = null; oObj.style.left = dr.style.left; oObj.style.top = dr.style.top; document.body.removeChild(dr); dr.releaseCapture ? dr.releaseCapture() : function(){}; oObj.style.zIndex = APIframe.zindex++; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -