Click here to Skip to main content
15,887,376 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a legacy C# javascript app that I've been asked to look at as some of the behaviours are not working in Chrome. I found the culprit to be showModalDialog

Below is the javascript function that I need to fix.
I have read all sorts of advice but the examples are very basic and do not meet my needs. This is a modal pop up window that has 2 lists, you can click on arrows to select fields and move them to the right side and vice versa. I hope this makes sense.

Any assistance is appreciated.

function launchFieldList() {     
        var args = new Object();
        buildList();
        args["listFields"] = listFields;  
        var retVal = showModalDialog("selectFields.aspx",
                      args,
                      "dialogWidth:650px;dialogHeight:410px;status:no");       
        if (retVal != new String("CANCEL") && typeof (retVal) != "undefined")
        {
                fieldList = retVal;
        }
        updateDisableSelection();       
        buildList();        		   
}


What I have tried:

I tried replacing it with window.open and that does pop up a new page, but its not modal and has no data - the fields list has not been returned. This happens on IE and Chrome.
Posted
Updated 24-Aug-20 1:08am
Comments
F-ES Sitecore 24-Aug-20 6:52am    
You're probably going to have to use a js plug-in that lets you show a web page in a modal box, or completely refactor your code so it is compatible with more traditional js modal plug-ins which will involve the contents of your modal being on the same page as the parent page.

1 solution

The MDN documentation[^] has a link to a polyfill for this method:
GitHub - niutech/showModalDialog: window.showModalDialog polyfill using a <dialog> element[^]

Alternatively, rewrite your code using the <dialog> element[^].

Or use an in-page Javascript "modal" dialog - for example, Bootstrap[^] or jQuery UI[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900