现在的位置: 首页 > 综合 > 正文

firefox中使用window.createPopup的问题

2017年04月13日 ⁄ 综合 ⁄ 共 1976字 ⁄ 字号 评论关闭

 

  1. if (!window.createPopup) {  
  2.     var __createPopup = function() {  
  3.         var SetElementStyles = function( element, styleDict ) {  
  4.             var style = element.style ;  
  5.             for ( var styleName in styleDict )style[ styleName ] = styleDict[ styleName ] ;   
  6.         }  
  7.         var eDiv = document.createElement( 'div' );   
  8.         SetElementStyles( eDiv, { 'position''absolute''top': 0 + 'px''left': 0 + 'px''width': 0 + 'px''height': 0 + 'px''zIndex': 1000, 'display' : 'none''overflow' : 'hidden' } ) ;  
  9.         eDiv.body = eDiv ;  
  10.         var opened = false ;  
  11.         var setOpened = function( b ) {  
  12.             opened = b;   
  13.         }  
  14.         var getOpened = function() {  
  15.             return opened ;   
  16.         }  
  17.         var getCoordinates = function( oElement ) {  
  18.             var coordinates = {x:0,y:0} ;   
  19.             while( oElement ) {  
  20.                 coordinates.x += oElement.offsetLeft ;  
  21.                 coordinates.y += oElement.offsetTop ;  
  22.                 oElement = oElement.offsetParent ;  
  23.             }  
  24.             return coordinates ;  
  25.         }  
  26.         return {htmlTxt : '', document : eDiv, isOpen : getOpened(), isShow : false, hide : function() { SetElementStyles( eDiv, { 'top': 0 + 'px''left': 0 + 'px''width': 0 + 'px''height': 0 + 'px''display' : 'none' } ) ; eDiv.innerHTML = '' ; this.isShow = false ; }, show : function( iX, iY, iWidth, iHeight, oElement ) { if (!getOpened()) { document.body.appendChild( eDiv ) ; setOpened( true ) ; } ; this.htmlTxt = eDiv.innerHTML ; if (this.isShow) { this.hide() ; } ; eDiv.innerHTML = this.htmlTxt ; var coordinates = getCoordinates ( oElement ) ; eDiv.style.top = ( iX + coordinates.x ) + 'px' ; eDiv.style.left = ( iY + coordinates.y ) + 'px' ; eDiv.style.width = iWidth + 'px' ; eDiv.style.height = iHeight + 'px' ; eDiv.style.display = 'block' ; this.isShow = true ; } }  
  27.     }  
  28.     window.createPopup = function() {  
  29.         return __createPopup();   
  30.     }  
  31. }  

抱歉!评论已关闭.