If you have a website being compatible with Edge/Chrome and in past it was only compatible with IE 11 and if you are using window.showModalDailog in your JavaScript code, then it will not work in modern browsers. Let’s check below its solution.

Below given sample JavaScript code that will not work because of showModalDailog in its 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";
        }
  }
}

Solution:

As an alternative, we can try to use Window.Open() (for Edge and Chrome browsers). You can check below code it will definitely solve given issue.

function ShowInfoBox(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, 'New Window', 'width=400, height=120, status=no');
            theWin.focus();
           }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

Explore More

How to Center a Popup Window on Screen

JavaScript window.open() method is used to open a popup window. This popup window will be placed in the center of the screen. This example creates the pop-up window without placing it into

How to hide URL in the popup window opened using window.open

If you are using below code to open a popup window in your web page, then address must be appearing in you pop up window and f you want to

Cloning JavaScript Object with Object.create

We present another article focusing on understanding the concept of creating objects using Object.create. The article will discuss the advantages and disadvantages of using “Object.create” to clone objects. Let’s take