Search code examples
javascriptjquerymicrosoft-edgeshowmodaldialog

window.showModalDialog totally deprecated in Edge


I have a website being compatible with Edge (it was only compatible with IE before...).

The problem is, I don't understand what to do with my old showModalDialog elements. I hoped that a simple workaround could exist, but I think it's hopeless. I need a returned value...

Here's my current code :

function openCalendar(oDate){
    if (typeof jQuery != 'undefined' && oDate instanceof jQuery) {
        var dateValue   = oDate.val();
        var color       = oDate.css('color');
    }else{
        var dateValue   = oDate.value;
        var color       = oDate.style.color;
    }

  var month     = "";
  var year      = "";

    if (dateValue != "" && color != "red") {
        month = dateValue.substring(3,5);
        year  = dateValue.substring(6,10);
    }
  search    = window.showModalDailog('../calendar/calendar.jsp?month='+month+'&year='+year ,null,'dialogWidth=220px;dialogHeight=220px;STATUS:NO;SCROLL:NO;help:no');

  if (search != null && search != "undefined" && search != "") {
        if (typeof jQuery != 'undefined' && oDate instanceof jQuery) {
            oDate.val(search);
            oDate.css('color', "");
        }
        else {
            oDate.value           = search;
            oDate.style.color   = "";
            oDate.className   = "InputText";
        }
  }
}

What should I do in my situation ?

Thank you for your help.

P.S.: I have to use jQuery 1.3.2


Solution

  • As an alternative, You can try to use Window.Open(). You can check it, whether it solves your issue or not.

    Code Example:

    function ShowInformationMessage(message) {
            var ie = document.all;
            varl url = '../TestWeb/Error/ErrorMessages/PopInfoUI.aspx?val=' + message
     
    
            if(ie)
               window.showModalDialog(url, 'window', 'status:no; help:no; dialogWidth:400px; dialogHeight:120px');
            else {
                var theWin = window.open(url, 'theWin', 'width=400, height=120, status=no');
                theWin.focus();
            }
        }