Let me explain: when you call alert () in JS, all the code below the warning will stop, and when you click OK, the code will return to work.
I create my own custom alert using this code:
function cAlert() { var bOn; this.show = function (content) { bOn = true; document.write('<div id="turnOffLight"></div><div id="cAlertBox"><div id="cAlertImageBox"><img style="position: absolute; top: 54%; left: 50%; margin-top: -32px; margin-left: -32px;" src="Images/Vectors/1429744831_678136-shield-warning-64.png" alt=""/> </div><div id="cAlertContentBox"> </div><div id="cAlertButtonBox"><input id="cAlertButtonStyle" type="button" value="OK" onclick="cAlert.ok()" /></div></div>'); $("#cAlertContentBox").html(content); $("#cAlertBox").show(); $("#turnOffLight").fadeIn("fast"); var div = document.getElementById('cAlertBox').offsetWidth; var res = -Math.abs(div / 2); document.getElementById('cAlertBox').style.marginTop = res + "px"; }; this.ok = function () { $("#cAlertBox").hide(); $("#turnOffLight").fadeOut("medium"); bOn = false; }; }
and on other pages:
<head> <script src="Scripts/jQuery_1.11.2.js" type="text/javascript"></script> <script src="Scripts/cAlertScript.js" type="text/javascript"></script> <script type="text/javascript">var cAlert = new cAlert();</script> </head>
but I have a problem on the login page after calling cAlert (), I call this:
echo "<script>javascript:history.go(-1)</script>";
to return to the last page, when I used the notification (), only after the user clicks in order, the browser will return to the last page, but with cAlert the browser will return to the last page.
I want the user to press the OK button so that the code continues as a warning ().
javascript alert
Junior VenΓ’ncio
source share