通过js打开浏览器独立的页面

兼容Chrome浏览器 window.showModalDialog 是IE浏览器特有的内置方法 window.showModalDialog let has_showModalDialog!!window.showModalDialo

兼容Chrome浏览器
window.showModalDialog 是IE浏览器特有的内置方法
window.showModalDialog

  let has_showModalDialog = !!window.showModalDialog;
      if(!has_showModalDialog &&!!(window.opener)){
          window.οnbefοreunlοad=function(){
              window.opener.hasOpenWindow = false;
          }
      }
  if(window.showModalDialog == undefined){
      window.showModalDialog = function(url,mixedVar,features){
          if(window.hasOpenWindow){
              window.myNewWindow.focus();
          }
          window.hasOpenWindow = true;
          if(mixedVar) var mixedVar = mixedVar;
          if(features) var features = features.replace(/(dialog)|(px)/ig,"").replace(/;/g,',').replace(/\:/g,"=");
          let left = (window.screen.width - parseInt(features.match(/width[\s]*=[\s]*([\d]+)/i)[1]))/2;
          let top = (window.screen.height - parseInt(features.match(/height[\s]*=[\s]*([\d]+)/i)[1]))/2;
          window.myNewWindow = window.open(url,"_blank",features);
      }
  }
// image.html 为显示的页面
 window.showModalDialog(`/image.html?src=${this.imageUrl}`, '', 'dialogWidth:300px;dialogHeight:380px;');

发布者:admin,转转请注明出处:http://www.yc00.com/web/1733226020a3651421.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信