最近在做ie11的兼容性问题,每次都会因为window.createPopup这个已经不支持,而导致会报一些稀奇古怪的错误,比如,var popup=window.createPopup之后,popup这个对象无法使用popup.document.getElementById,会报SCRIPT438: 对象不支持“getElementById”属性或方法这个错,现在终于解决的,,只要在每次调用之前加一个兼容性判断就OK,判断方法如下

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();   }
}  

然后在接上

var winPopup = window.createPopup(); //Create the window to popup

这样就可以了。

ie11不兼容window.createPopup的问题解决相关推荐

  1. html引入vue不兼容ie11,关于vue.js:iview按需引入ie11不兼容报无效字符问题解决

    筹备工作 //借助插件 npm install babel-plugin-import --save-dev // .babelrc { "plugins": [["im ...

  2. 使用window.createPopup创建无限级跨帧下拉菜单

    我的BLOG搬家到自己的站点了 站点链接 RSS   先帖样子      使用层或者其他技术所实现的JS菜单不能解决的问题就是这些菜单不能跨帧,也就是说在Frame之间的时候无可奈何,所幸的是IE5+ ...

  3. 如何让火狐浏览器兼容window.event

    遇到一个问题,火狐不兼容window.event,之前代码解决是通过这种方式解决的. 如下(无参数方式): unction _test2() { var evt = window.event || a ...

  4. window.createPopup()用法以及短消息提示框代码

    一.在做一个portal项目时,用户要求在门户首页上的待办信息要有明确的提示,且在浏览器最小化的情况下,当有新的待办信息时,也要做提示.用了alert方法.或者用div的方法都很难实现"在浏 ...

  5. 增加对IE11的兼容

    <meta content="IE=11.0000" http-equiv="X-UA-Compatible" /><!--增加对IE11的兼 ...

  6. IE11不兼容array.from()解决方法

    function selectAll(){ let check = Array.from(document.getElementsByClassName("chk"));check ...

  7. 高版本Chrome兼容window.showModalDialog办法

    高版本Chrome兼容window.showModalDialog办法 方式一:回调 兼容方式: 由于showmodaldialog 不属于W3C标准,在新版本浏览器中不再受支持,我们需要使用wind ...

  8. ie11不兼容 html编辑器,ie11兼容性视图护驾浏览网页

    安装 ie11 后,原来的在线网页编辑器不能粘贴.也不能插入图片了,有些网站也不能登录,怪不适用的,无奈只能启用ie11兼容模式.把显示或操作不正常的网站添加到兼容性视图后,又可以操作了,好在ie有兼 ...

  9. ie11不兼容java_IE11浏览器网页不兼容的四种解决方法

    Edge浏览器已然成为最新win10系统的默认浏览器,但是用户量却远远不及IE11,IE11虽然性能得到了大的改进,但在浏览网页的时候还是会出现一些兼容性的问题,下面小编就讲为大家分享IE 11浏览器 ...

最新文章

  1. nginx LB服务器配置
  2. 騰訊大廈有39層的問題解決方案。
  3. Arcgis自下而上从左到右进行编号
  4. Java File类详解
  5. PostgreSQL大版本升级(pg_upgrade)11.7升12.2
  6. ZooKeeper官方文档学习笔记03-程序员指南03
  7. 质量标准、质量策略和质量责任的概念解释
  8. django、tornado、flask对比
  9. Java_8排序(冒泡排序和选择排序)
  10. loki日志收集系统部署
  11. linux下这输入法切换大小写,Life With Arch:让Capslock成为输入法切换快捷键
  12. PCIe 1. PCI与PCIe学习一——硬件篇
  13. PowerBI-时间智能函数-SAMEPERIODLASTYEAR
  14. 揭秘收入中常见的避税方法
  15. 【源码分享】一键打开禅意生活——电子木鱼微信小程序源码分享
  16. 外置MOS 开关型 PWM调光 降压恒流驱动芯片
  17. win11动手学深度学习安装过程(GPU版)( CUDA Anaconda Mxnet )
  18. Mac 移动硬盘无法装载
  19. VMware虚拟机安装Ubuntu时页面显示不全的解决方法
  20. 先知社区-文章爬虫-python脚本

热门文章

  1. 【es】elasticsearch生产数据备份和恢复方案
  2. 无题--仅以此文来总结我过去的五年
  3. OpenWrt-路由器上的linux
  4. C++ 使用Poco库实现日志操作
  5. java 过滤所有特殊字符
  6. iphone 信号对应设备_如果iPhone收到不良信号该怎么办
  7. VUE3 响应式 API 之 toRef 与 toRefs
  8. supervisor安装使用
  9. android 视频背景图片,安卓手机怎么给视频添加背景图片 上下图片中间视频画面的小视频制作...
  10. iOS - 选取相册中iCloud云上图片和视频的处理