Doug Null Doug Null - 6 months ago 45
HTML Question

how to keep web page displayed during JavaScript alert in Chrome & FireFox for a VB ASP.NET web app

Is there a way to keep page displayed in background while alert popup is displayed?
(IE keeps it displayed)

In my VB ASP.NET web app, I popup an alert by using JavaScript alert(). (see code below)
But when alert pops up, Chrome and FF web page goes blank until user hits OK, then it is re-displayed. (IE doesn't have problem)

' Shows javascript alert_message at browser, because MsgBox doesn't work there.
Private Sub alert(ByVal alert_message As String)
Dim msg As String
msg = "<script language='javascript'>"

msg += "alert('" & POPUP_ALERT_TITLE & "\n\n" & alert_message & "');"

msg += "<" & "/script>"
Response.Write(msg)
End Sub


SAMPLE USAGE WITHIN MY VISUAL BASIC 2013 ASP.NET WEB APP..........

Function sample_usage()
alert("INTERNAL ERROR 111.")
End Function

Answer

This fixed it:

Private Sub alert(ByVal alert_message As String)
Dim msg As String
msg = "<script language='javascript'>"

' The 100 ms delay prevents a blank page during alert, in Chrome and FireFox:
msg += "setTimeout(function(){alert('" & POPUP_ALERT_TITLE & "\n\n" & alert_message & "')}, 100);"

msg += "<" & "/script>"
Response.Write(msg)

End Sub