Uncaught TypeError: window.showModalDialog is not a function chrome 谷歌瀏覽器

//新版本谷歌沒有window.showModalDialog,創建一個window.open
if(window.showModalDialog == undefined){  
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);  
        }  

}


在使用回調的時候

var parent;
//谷歌的情況下
 if (window.opener != undefined) {
   parent=window.opener;
 }    
 else {   

          parent=window.dialogArguments;
}  


只要當谷歌瀏覽器使用window.showModalDialog未定義的時候,就可以使用window.open這個來替代!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章