window.showModalDialog is not a function

发布时间:2018-11-08编辑:佚名阅读(4145)

按F12打开调试器发现window.showModalDialog()这个函数没有定义

解决方法:

$(function(){
    if(window.showModalDialog == undefined){
        //alert("初始化的时候,判断window.showModalDialog是否存在")
        window.showModalDialog = function(url,mixedVar,features){
            window.hasOpenWindow = true;
            if(mixedVar) var mixedVar = mixedVar;
            if(features) var features = features.replace(/(dialog)|(px)/ig,"").replace(/;/g,',').replace(/\:/g,"=");
            window.myNewWindow = window.open(url,"_blank",features);
        }
    }
});

一加载页面的时候,我们就判断这个方法是否是undefined未定义的,如果是,我们给window.showModalDialog()重新赋予新的函数,原来的代码不变

  关键字:window.showModalDialogis not a function


鼓掌

2

正能量

0

0

呵呵

2


评论区