My project was totally involved in asp.net, We are working on browser compatibility issues,
window.showModalDialog
is not working in chr
There is no real replacement for showModalDialog. You could use window.open to open the dialog subpage and then use the window.opener to update the controls on the parent page. This would not work in the client javascript when waiting for a result value from the dialog subpage. The only way to create a sync call to a subpage is to use JQuery with Ajax.
Make sure you include JQuery in the page head. Note: need the full JQuery that contains the ajax functions.
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
Then add a new function in the client javascript to make the Ajax call. Note the ajax function has to be set to async: false so the client javascript waits for a result.
// -------------------------------------------------------------------------------------
// Name: GetJSONdlgResult
// Description: Ajax get request to the dialog Subpage to replace ShowModalDialog function.
// Uri should already have all the parameters needed
// dialog SubPage will need the following code added to the final ASP vbscript function:
// ------------------------------------------------------------------------
// ' Clear whatever is currently on the page
// Response.Clear
// ' build the JSON Results from the sErrMsg variable
// Dim JSON_Results
// JSON_Results = "{" & chr(34) & "returnValue" & chr(34) & ":" & chr(34) & sErrMsg & chr(34) & "}"
// ' Setup the JSON response header
// Response.ContentType = "application/json"
// ' Write it to the response and end it
// Response.Write JSON_Results
// Response.Flush
// Response.End
// -------------------------------------------------------------------------------------
function GetJSONdlgResult(strUrl) {
var strResult = "Fail";
try {
var Request = $.ajax({
url: strUrl,
dataType: "json",
type: "get",
async: false, // async must be false so the javascript function waits for the subpage result like ShowModalDialog
success: function (data) {
// JSON object from the ajax call.
strResult = data.returnValue; // This could be any JSON result returned from the subpage
}
});
}
catch (err) {
alert(err);
}
return strResult
}
Then add the following vbScript Code in the ASP dialog subpage to clear the dialog page and convert the response to JSON format.
' Clear whatever is currently on the page
Response.Clear
' build the JSON Results from the sErrMsg ASP Server variable
Dim JSON_Results
JSON_Results = "{" & chr(34) & "returnValue" & chr(34) & ":" & chr(34) & sErrMsg & chr(34) & "}"
' Setup the JSON response header
Response.ContentType = "application/json"
' Write it to the response and end it
Response.Write JSON_Results
Response.Flush
Response.End
Replace the showModalDialog calls in the client javascript with the new javascript function GetJSONdlgResult
//var sRetValue = window.showModalDialog(sURL);
var sRetValue = GetJSONdlgResult(sURL);
Hi if your concern is that u can edit the parent window even after opening the popup(Which was not the case with showModalDialog), then u can use code something like this using window.open()
<html>
<head>
<script type="text/javascript">
var popupWindow=null;
function child_open()
{
if(popupWindow && !popupWindow.closed)
popupWindow.focus();
else
popupWindow =window.open('(Any html file)',"_blank","directories=no, status=no, menubar=no, scrollbars=yes, resizable=no,width=600, height=280,top=200,left=200");
}
function parent_disable() {
if(popupWindow && !popupWindow.closed)
popupWindow.focus();
}
</script>
</head>
<body onFocus="parent_disable();" onclick="parent_disable();">
<a href="javascript:child_open()">Click me</a>
</body>
</html>
You could use polyfills to resolve this issue. Click here for more details
Another link that could help