標籤:style io ar color os 使用 sp java strong
子視窗通用介面,基於jQuery支援使用。目前設計時,使用的是1.7.2版。FF預設焦點未失去問題存在。
HTML & JS:
<html> <head> <title></title> <script charset="GB2312" type="text/javascript" src="js/jquery-1.7.2.js"></script> <script type="text/javascript"> var flag = true; $(document).ready(function() { // 確認處理 $("#butn").click(function() { if (flag) { openArea("InfoWndw", "<input type=\"button\" id=\"clos\" value=\"關閉\" onclick=\"javascript:closArea(‘InfoWndw‘);\"/>MSGE CONT.", "1"); flag = false; } else { openArea("InfoWndw", "<table border=‘1‘><tr><td>HTML TABL CONT</td></tr></table>", ‘1‘ ); flag = true; } }); }); // 子視窗開啟 function openArea(itemId, cont, type) { // 鎖定背景地區顯示 $("#DVID_LOCK_VIEW").show(500); // 視窗展示內容設定 if ("1" == type) { // 追加內容 $("#" + itemId).append(cont); } else if ("2" == type) { // 設定內容 $("#" + itemId).text(cont); } else { // 設定HTML $("#" + itemId).html(cont); } // 地區左上方上邊距 var areaTidx = 0; // 地區左上方左邊距 var areaLidx = 0; // 視窗高度 var wndwHigh = $(window).height(); // 視窗寬度 var wndwWdth = $(window).width(); // 地區高度 var areaHigh = $("#" + itemId).height(); // 地區寬度 var areaWdth = $("#" + itemId).width(); // 左上方起始位置計算(上邊距) if (wndwHigh > areaHigh) { // 視窗高度大於地區高度時,計算上邊距中間位置 areaTidx = (wndwHigh - areaHigh) / 2; } // 左上方起始位置計算(左邊距) if (wndwWdth > areaWdth) { // 視窗寬度大於地區寬度時,計算左邊距中間位置 areaLidx = (wndwWdth - areaWdth) / 2; }// // 各屬性節點的屬性值測試資訊// alert("視窗:H-W : " + wndwHigh + ":" + wndwWdth + "\r\n地區:H-W : " + areaHigh + ":" + areaWdth + "\r\n位置:H-W : " + areaTidx + ":" + areaLidx); // 左上方定位設定 $("#" + itemId).css("top", areaTidx).css("left", areaLidx); // 地區模組顯示 $("#" + itemId).show(1000); // 焦點移入 $("#" + itemId).focus(); } // 子視窗關閉 function closArea(itemId) { // 地區模組顯示 $("#" + itemId).empty(); // 地區模組顯示 $("#" + itemId).hide(500); // 鎖定背景地區清理 $("#DVID_LOCK_VIEW").hide(1000); } </script> </head> <body> <!-- W:<input id="wdth"/> H:<input id="high"/> --> <input type="button" id="butn" value="顯示"/> <div id="DVID_LOCK_VIEW" style="display:none;position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:#336699;z-index:9998;-moz-opacity:0.6;opacity:.60;filter:alpha(opacity=60);"></div> <span id="InfoWndw" style="position:absolute;background:#6699CC;display:none;z-index:9999;"></span> </body></html>
LvCreator 著作權...
DIV/SPAN通用子視窗展現、關閉JS介面