兼容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;');
兼容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;');