http://www.aygfsteel.com/ebecket 返還網
          隨筆-140  評論-11  文章-131  trackbacks-0
          //Xingmai命名空間
          if(!Xingmai)
          var Xingmai = {};

          //內容窗口
          Xingmai.ContentBox =
          {
          //創建窗口
          CreateBox : function()
          {
          //創建窗體
          var contentBox = {};

          //ID
          contentBox.ID = null;

          //窗口Title
          contentBox.Title = null;

          //窗口寬度
          contentBox.Width = null;

          //窗口高度
          contentBox.Height = null;

          //窗口左像素
          contentBox.Left = null;

          //窗口頂像素
          contentBox.Top = null;

          //Class定義
          contentBox.ClassName= null;

          //默認值
          contentBox.Common = {
          Width : 500,
          Height : 400,
          Left : (document.documentElement.clientWidth - contentBox.Width)/2 + document.documentElement.scrollLeft,//有問題
          Top : (document.documentElement.clientHeight - contentBox.Height)/2 + document.documentElement.scrollTop //有問題
          };
          //創建BOX
          contentBox.Create = function()
          {
          //alert("a");
          //創建主要界面
          var newBox = document.createElement("div");
          newBox.setAttribute("id", contentBox.ID);
          with(newBox.style)
          {
          position = "absolute";
          zIndex = "9999";
          width = contentBox.Width + "px";
          height = contentBox.Height + "px";
          top = contentBox.Top;
          left = contentBox.Left;
          }
          //newBox.setAttribute("style", "width : " + contentBox.Width + "px; height : " + contentBox.Height + "px;");
          if(contentBox.ClassName!=null)
          newBox.setAttribute("className", contentBox.ClassName);

          //創建標題欄和刪除按鈕
          var titleSpan = document.createElement("div");
          with(titleSpan.style)
          {
          height = "20px";
          textAlign = "left";
          verticalAlign = "middle";
          }
          //titleSpan.setAttribute("style", "height : " + "35" + "px;");
          titleSpan.setAttribute("class","contentTitleSpan");
          var spanDiv = document.createElement("div");
          with(spanDiv.style)
          {
          width = contentBox.Width - 30 + "px";
          styleFloat = "left";
          textAlign = "left";
          }
          spanDiv.appendChild(document.createTextNode(contentBox.Title));
          titleSpan.appendChild(spanDiv);

          var closeDiv = document.createElement("div");
          with(closeDiv.style)
          {
          width = "20px";
          styleFloat = "right";
          textAlign = "right";
          }
          var closeButton = document.createElement("a");
          closeButton.setAttribute("href", "#");
          closeButton.appendChild(document.createTextNode("×"));
          $addHandler(closeButton,"click", function(){Xingmai.ContentBox.KillBox(contentBox.ID);});
          closeDiv.appendChild(closeButton)
          titleSpan.appendChild(closeDiv);
          newBox.appendChild(titleSpan);

          //創建Iframe
          var iframe = document.createElement("iframe");
          iframe.setAttribute("class","contentIframe")
          iframe.setAttribute("src" , contentBox.Url);
          iframe.setAttribute("frameborder","0",0);
          iframe.setAttribute("scrolling","no");
          with(iframe.style)
          {
          border = "0";
          width = "100%";
          height = (contentBox.Height - 20) + "px";
          }
          newBox.appendChild(iframe);

          return newBox;
          };

          //創建ID
          contentBox.CreateID = function()
          {
          var now = new Date();
          return "ContentBox" + now.getFullYear() + now.getMonth() + now.getDay() + now.getHours() + now.getMinutes() + now.getSeconds() + now.getMilliseconds();
          };

          //顯示窗口
          contentBox.Show = function()
          {
          //處理默認值
          contentBox.ID = contentBox.ID == null ? contentBox.CreateID() : contentBox.ID;
          contentBox.Title = contentBox.Title == null ? "內容系統窗口" : contentBox.Title;
          contentBox.Url = contentBox.Url == null ? "about:blank" : contentBox.Url;
          if(isNaN(contentBox.Width)||contentBox.Width == null)
          contentBox.Width = contentBox.Common.Width;
          if(isNaN(contentBox.Height)||contentBox.Height == null)
          contentBox.Height = contentBox.Common.Height;
          if(isNaN(contentBox.Left)||contentBox.Left == null)
          contentBox.Left = contentBox.Common.Left;
          if(isNaN(contentBox.Top)||contentBox.Top == null)
          contentBox.Top = contentBox.Common.Top;

          //創建窗口并顯示
          var add = contentBox.Create();
          document.getElementsByTagName("body").item(0).appendChild(add);
          };

          return contentBox;
          },

          //刪除窗口
          KillBox : function(id)
          {
          var box= document.getElementById(id);
          if(box)
          box.parentNode.removeChild(box);
          }
          };
          posted on 2010-02-28 23:50 becket_zheng 閱讀(288) 評論(0)  編輯  收藏 所屬分類: 網頁web前端技術
          主站蜘蛛池模板: 绍兴市| 玛沁县| 咸阳市| 宣威市| 新蔡县| 穆棱市| 三穗县| 奈曼旗| 沁源县| 余姚市| 民乐县| 扶余县| 镇宁| 文山县| 乳山市| 林西县| 唐山市| 二连浩特市| 清丰县| 涟源市| 盐津县| 麟游县| 定安县| 东莞市| 东丰县| 泰州市| 精河县| 泸定县| 宁国市| 石渠县| 睢宁县| 德昌县| 徐汇区| 宜宾县| 环江| 定结县| 柳江县| 西充县| 江津市| 锡林郭勒盟| 溧阳市|