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
Javascript executes on a single thread. Alert boxes interrupt that thread, causing it to hang until the user closes it. See this jsFiddle for an example.
<div id="messages">
</div>
<script>
alert('test');
$('#messages').text( 'alert is done!' );
</script>
What's likely happening is that you have some Javascript which is reloading portions of the page. IE is executing things in a particular order, and Chrome and Firefox are doing things in a slightly different order (or are doing things faster/slower). So in IE, the page underneath has finished (or not started) loading/reloading while in Chrome and Firefox the page is in the middle of loading/reloading.
Unfortunately, there's no simple solution to this... any answer will involve changing your Javascript a bit. I'd recommend using something like blockUI and then showing things like alerts after a timeout (to give other parts of your Javascript a chance to finish).
您也可以这样写:
Response.write("<script type=""text/javascript"">setTimeout(function(){alert("" type your message here"")},100);</script>")
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.