




下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)
文檔簡介
1、用DIV實現(xiàn)彈出窗口.txt你無法改變別人,但你可以改變自己;你無法改變天氣, 但你可以改變心情; 你無法改變生命長度, 但你可以拓展它的寬度。 用DIV實現(xiàn)彈出窗口2008-04-08 11:12/*創(chuàng)建彈出div窗口。1、 接口說明:DivWindow(id,title,width,height,content)建一個彈出窗口對象參數(shù):titlewidthheightcontentcloseDivWindow(id)關(guān)閉窗口id彈出窗口id4、接口說明:setPopupTopBgColor(tBgColor)設(shè)置彈出窗口標(biāo)題背景顏色5、 接口說明:setPopupColor(borderC
2、olor,bgColor,tFontColor,cBgColor,fColor)設(shè)置彈出窗 口風(fēng)格,包括標(biāo)題欄的背景, 彈出窗口邊框顏色, 內(nèi)容窗體背景顏色,內(nèi)容窗體字 體顏色6、接口說明:open()使用方法:var a = new DivWindow(1,窗口測試,580,400,Welcome to visitedmy personal website:http:/ahref=http:/thx!=).L);a.setPopupTopBgColor(black,blue,white,white,black);a.open();生成的html:控制背景的div,使背景逐漸變暗titleid
3、彈出窗口id;: 彈出窗口標(biāo)題名稱;:彈出窗口寬度:彈出窗口高度: 彈出窗口顯示內(nèi)容2、 接口說明:參數(shù):3、接口說明:窗口標(biāo)題字體顏色參數(shù):setPopupTopTitleFontColor(PopupTopTitleFontColor)設(shè)置彈出構(gòu)造函數(shù),創(chuàng)maxORminclosecontent author Nieger Daidate 2007.11.15*/var isIe = (document.all)?true:false; var moveable=false;var topDivBorderColor =#336699;/ var topDivBgColor =#6795B
4、4;/ var contentBgColor =white;/ var contentFontColor =black;/ var titleFontColor =white; / varindex=10000;/z-index;/創(chuàng)建彈出窗口,構(gòu)造函數(shù)function DivWindow(id,title,w,h,content)this.id = id;/窗口id this.zIndex = index 2;this.title = title;/彈出窗口名稱this.message = content;/彈出窗口內(nèi)容this.width = w;/彈出窗口寬度this.height =
5、h;/彈出窗口高度this.left = (document.body.clientWidth) ? (document.body.clientWidth -this.width)/2 : 0;/彈出窗口位置,距屏幕左邊的位置this.top =(document.body.clientHeight) ? (document.body.clientHeight -this.height)/2 : 0;/彈出窗口位置,距屏幕上邊的位置/this.init = init;/this.init();/根據(jù)構(gòu)造函數(shù)設(shè)定初始值,創(chuàng)建彈出窗口DivWtotype = /設(shè)置彈出窗口標(biāo)題字
6、體顏色setPopupTopTitleFontColor:function(tFontColor)titleFontColor = tFontColor;,/設(shè)置彈出窗口標(biāo)題背景顏色setPopupTopBgColor:function(tBgColor)topDivBgColor = tBgColor;,/設(shè)置彈出窗口風(fēng)格,包括標(biāo)題欄的背景,彈出窗口邊框顏色,內(nèi)容窗體背景顏 色,內(nèi)容窗體字體顏色setPopupColor:function(borderColor,bgColor,tFontColor,cBgColor,fColor)提示窗口的邊框顏色 提示窗口的標(biāo)題的背景顏色 內(nèi)容顯示窗口的
7、背景顏色 內(nèi)容顯示窗口字體顏色 彈出窗口標(biāo)題字體顏色topDivBorderColor = borderColor; topDivBgColor = bgColor; titleFontColor= tFontColor; contentBgColor = cBgColor;contentFontColor = fColor;,/打開一個彈出窗口open: function()var sWidth,sHeight;sWidth=document.body.clientWidth; sHeight=document.body.clientHeight;var bgObj=document.cre
8、ateElement(div);bgObj.setAttribute(id,window this.id);var styleStr=top:0px;left:0px;position:absolute;background:#245;width:sWidth px;height: sHeight px;styleStr =(isIe)?filter:alpha(opacity=0);:opacity:0;bgObj.style.cssText=styleStr; document.body.appendChild(bgObj);/讓背景逐漸變暗showBackground(bgObj,25)
9、;/彈出窗口框體背景容器var windowTopBgDiv = document.createElement(div);windowTopBgDiv.setAttribute(id,windowTopBg this.id);windowTopBgDiv.style.position = absolute; windowTopBgDiv.style.zIndex =this.zIndex ; windowTopBgDiv.style.width = this.width ;windowTopBgDiv.style.height = this.height; windowTopBgDiv.sty
10、le.left =this.left; windowTopBgDiv.style.top = this.top;windowTopBgDiv.style.background = topDivBgColor;windowTopBgDiv.style.fontSize = 9pt;windowTopBgDiv.style.cursor = default; windowTopBgDiv.style.border =1px solid topDivBorderColor;windowTopBgDiv.attachEvent(onmousedown,function() if(windowTopBg
11、Div.style.zIndex!=index)index = index 2;var idx = index;windowTopBgDiv.style.zIndex=idx;);/彈出窗口頭部框體var windowTopDiv = document.createElement(div);windowTopDiv.setAttribute(id,windowTop this.id);windowTopDiv.style.position = absolute; windowTopDiv.style.background =topDivBgColor;/white; windowTopDiv.
12、style.color = titleFontColor;windowTopDiv.style.cursor = move; windowTopDiv.style.height = 20;windowTopDiv.style.width = this.width-2*2;/開始拖動;windowTopDiv.attachEvent(onmousedown,function() if(event.button=1)/鎖定標(biāo)題欄;windowTopDiv.setCapture();/定義對象;var win = windowTopDiv.parentNode;/記錄鼠標(biāo)和層位置;x0 = even
13、t.clientX;y0 = event.clientY;x1 = parseInt(win.style.left);y1 = parseInt(win.style.top);/記錄顏色;/topDivBgColor = windowTopDiv.style.backgroundColor;/改變風(fēng)格;/windowTopDiv.style.backgroundColor = topDivBorderColor;win.style.borderColor = topDivBorderColor;moveable = true;);/停止拖動windowTopDiv.attachEvent(on
14、mouseup,function() if(moveable)var win = windowTopDiv.parentNode; win.style.borderColor = topDivBgColor;windowTopDiv.style.backgroundColor = topDivBgColor;windowTopDiv.releaseCapture();moveable = false;);/開始拖動windowTopDiv.attachEvent(onmousemove,function() if(moveable)var win = windowTopDiv.parentNo
15、de; win.style.left = x1 event.clientX - x0;win.style.top = y1 event.clientY - y0;);/雙擊彈出窗口windowTopDiv.attachEvent(ondblclick,function() maxOrMinPopupDiv(windowTopOperateSpan,windowContentDiv); );/增加一個彈出窗口標(biāo)題的顯示var windowTopTitleSpan = document.createElement(span);windowTopTitleSpan.setAttribute(id,w
16、indowTopTitle this.id);windowTopTitleSpan.style.width = this.width-2*12-4;windowTopTitleSpan.style.paddingLeft = 3px;windowTopTitleSpan.innerHTML = this.title;/增加一個彈出窗口最小化,最大化的操作var windowTopOperateSpan = document.createElement(span);windowTopOperateSpan.setAttribute(id,windowTopOperate this.id);win
17、dowTopOperateSpan.style.width = 12;windowTopOperateSpan.style.borderWidth = 0px;windowTopOperateSpan.style.color = titleFontColor;/white;windowTopOperateSpan.style.fontFamily = webdings;windowTopOperateSpan.style.cursor = default;windowTopOperateSpan.innerHTML = 0;/最大化或者最小化彈出窗口操作windowTopOperateSpan
18、.attachEvent(onclick,function() maxOrMinPopupDiv(windowTopOperateSpan,windowContentDiv););/增加一個彈出窗口關(guān)閉的操作var windowTopCloseSpan = document.createElement(span);windowTopCloseSpan.setAttribute(id,windowTopClose this.id);windowTopCloseSpan.style.width = 12;windowTopCloseSpan.style.borderWidth = 0px;wind
19、owTopCloseSpan.style.color = titleFontColor;/white;windowTopCloseSpan.style.fontFamily = webdings;windowTopCloseSpan.style.cursor = default;windowTopCloseSpan.innerHTML = r;/關(guān)閉窗口windowTopCloseSpan.attachEvent(onclick,function() windowTopDiv.removeChild(windowTopTitleSpan);windowTopDiv.removeChild(wi
20、ndowTopOperateSpan);windowTopDiv.removeChild(windowTopCloseSpan);windowTopBgDiv.removeChild(windowTopDiv);windowTopBgDiv.removeChild(windowContentDiv);document.body.removeChild(windowTopBgDiv);document.body.removeChild(bgObj););/內(nèi)容var windowContentDiv = document.createElement(div);windowContentDiv.s
21、etAttribute(id,windowContent this.id);windowContentDiv.style.background = contentBgColor;windowContentDiv.style.color = contentFontColor;windowContentDiv.style.cursor = default; windowContentDiv.style.height= (this.height - 20 - 4); windowContentDiv.style.width = 100%;windowContentDiv.style.position
22、 = relative; windowContentDiv.style.left= 0; windowContentDiv.style.top = 24;windowContentDiv.style.lineHeight = 20px;windowContentDiv.style.fontSize = 10pt;windowContentDiv.style.wordBreak = break-all;windowContentDiv.style.padding = 3px; windowContentDiv.innerHTML =this.message;/將內(nèi)容寫入到文件中windowTop
23、Div.appendChild(windowTopTitleSpan);windowTopDiv.appendChild(windowTopOperateSpan);windowTopDiv.appendChild(windowTopCloseSpan);windowTopBgDiv.appendChild(windowTopDiv);windowTopBgDiv.appendChild(windowContentDiv);document.body.appendChild(windowTopBgDiv);/function maxOrMinPopupDiv(windowTopOperateS
24、pan,windowContentDiv)var win = windowTopOperateSpan.parentNode.parentNode;var tit = windowTopOperateSpan.parentNode;var flg = windowContentDiv.style.display=none;if(flg)win.style.height = parseInt(windowContentDiv.style.height)parseInt(tit.style.height) 2*2;windowContentDiv.style.display = block;win
25、dowTopOperateSpan.innerHTML = 0;elsewin.style.height=parseInt(tit.style.height)2*2;windowTopOperateSpan.innerHTML=2;windowContentDiv.style.display = none;/function showBackground(obj,endInt)if(isIe)obj.filters.alpha.opacity =1;if(obj.filters.alpha.opacityendInt) 最大或者最小化探出窗口讓背景漸漸變暗setTimeout(function()this.showBackground(obj,endInt),5); elsevar al=parseFloat(obj.style.opacity);al =0.01; obj.style.opacity=a
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 蜜蜂養(yǎng)殖技術(shù)試題及答案
- 面試必 備:巡考團面試題庫全解析
- 市場營銷崗位面試題庫:徽商面試常見話題與答題技巧
- 頭條面試常見問題及答案深度解析:高級編輯崗位面試攻略
- 學(xué)校開學(xué)安全知識培訓(xùn)課件
- 新文旅員工面試實戰(zhàn)題庫
- 工會面試實戰(zhàn)題庫:高級編輯技巧與面試題目解析
- 學(xué)校衛(wèi)生應(yīng)急知識培訓(xùn)課件教學(xué)
- 學(xué)前教育基本知識培訓(xùn)課件
- 六年級數(shù)學(xué)上冊第四單元《比(一)》重難點題型練習(xí)(含答案)
- 血液透析患者的心理護理
- 鋼欄桿安裝工程施工方案
- 《特種設(shè)備安全培訓(xùn)課件》
- 現(xiàn)代醫(yī)學(xué)中石墨烯的科研進展及市場前景預(yù)測
- 四川省成都市2024-2025學(xué)年度高一上學(xué)期期末考試語文試題(含答案)
- 高中數(shù)學(xué)開學(xué)第一課課件(初高中銜接)
- 高空作業(yè)車安全知識培訓(xùn)
- 電影美術(shù)課程設(shè)計
- 修腳服務(wù)行業(yè)未來三年發(fā)展洞察及預(yù)測分析報告
- 2024年京津冀公民科學(xué)素質(zhì)大賽參考試題庫(含答案)
- 水果收貨標(biāo)準(zhǔn)
評論
0/150
提交評論