firefox中使用window.createPopup的问题
2010-02-09 11:22
323 查看
火狐中使用window.createPopup(),兼容ie的解决办法:
if (!window.createPopup) { var __createPopup = function() { var SetElementStyles = function( element, styleDict ) { var style = element.style ; for ( var styleName in styleDict )style[ styleName ] = styleDict[ styleName ] ; } var eDiv = document.createElement( 'div' ); SetElementStyles( eDiv, { 'position': 'absolute', 'top': 0 + 'px', 'left': 0 + 'px', 'width': 0 + 'px', 'height': 0 + 'px', 'zIndex': 1000, 'display' : 'none', 'overflow' : 'hidden' } ) ; eDiv.body = eDiv ; var opened = false ; var setOpened = function( b ) { opened = b; } var getOpened = function() { return opened ; } var getCoordinates = function( oElement ) { var coordinates = {x:0,y:0} ; while( oElement ) { coordinates.x += oElement.offsetLeft ; coordinates.y += oElement.offsetTop ; oElement = oElement.offsetParent ; } return coordinates ; } 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 ; } } } window.createPopup = function() { return __createPopup(); } }
相关文章推荐
- firefox中使用window.createPopup的问题
- Android Popupwindow使用问题
- 使用window.createPopup创建无限级跨帧下拉菜单
- 使用window.createPopup创建无限级跨帧下拉菜单
- 解决firefox在未触发事件前无法使用window.event的问题
- 关于Android4.0及以下系统版本使用PopupWindow.dismiss()时内部的Drawable透明的问题
- 使用window.createPopup();做的简单下拉菜单
- Android PopupWindow悬浮弹框使用及解决back键点击不消失的问题
- 使用软引用解决Handler内存泄露和显示Popupwindow、Dialog时提示"Unable to add Window-token is null"的问题
- 使用window.createPopup()创建菜单
- ie11不兼容window.createPopup的问题解决
- 使用软引用解决Handler内存泄露和显示Popupwindow、Dialog时提示"Unable to add Window-token is null"的问题
- popupWindow使用timePicker时点击出现闪屏问题的解决办法
- 使用软引用解决Handler内存泄露和显示Popupwindow、Dialog时提示"Unable to add Window-token is null"的问题
- 使用window.createPopup();做的简单下拉菜单
- 使用window.createPopup();做的简单下拉菜单
- Android PopupWindow 与 软键盘 的遮挡问题解决
- springMVC框架在js中使用window.location.href请求url时IE不兼容问题解决
- popwindow实际开发使用中出现的问题(四)
- javascript使用window.name解决跨域问题第1/2页