Insert Function Only If No Exist

3

The "window.showModalDialog" function exists in some versions of IE, but does not exist in Chrome, I would like to insert it if it does not exist. How can I do this?

window.showModalDialog = function (arg1, arg2, arg3) { 
//Minha função
}
    
asked by anonymous 05.02.2016 / 15:19

1 answer

3

This feature is not standardized, deprecated, and should be avoided .

I think you put different issues here, and interesting to separate.

How / when to apply a polyfill

You can detect if the function exists and if you do not apply a function of yours with similar behavior. Something like:

if (!window.showModalDialog) window.showModalDialog = function(){
    // etc ...

How to reproduce this functionality (ie how to create a polyfill for this method)?

This already exists and you can find it in Github here: link

MDN also points to this repository that has a demo here .

    
05.02.2016 / 15:27