小编Jun*_*cio的帖子

停止所有代码并继续,就像JS中的alert()一样

让我解释一下:当您在JS中调用alert()时,警报下方的所有代码都将停止,当您单击Ok时,代码将返回工作.

我使用以下代码创建自己的自定义警报:

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;
};
}
Run Code Online (Sandbox Code Playgroud)

在其他页面中:

<head>
    <script src="Scripts/jQuery_1.11.2.js" type="text/javascript"></script>
    <script src="Scripts/cAlertScript.js" type="text/javascript"></script>
    <script …
Run Code Online (Sandbox Code Playgroud)

javascript alert

7
推荐指数
1
解决办法
1074
查看次数

标签 统计

alert ×1

javascript ×1