Sweetalert对话框不会显示

时间:2016-02-15 17:21:58

标签: javascript html5 css3 dialog sweetalert

window.alert = function (text) {
    swal({
        title: "Computer says:",
        text: text,
        timer: 3000,
        animation: "slide-from-top"
    });
    return true;
};

function run(input) {
    if (input[0] == "alert") {
        ta = input.slice(1, input.length);
        tap = ta.join(" ");
        alert(tap);
    }
}

当我致电run(["alert", "hello"]); in the javascript console时,它运作正常。 但是当我type in alert hello, in my console时,对话框会短暂闪烁并消失。这里发生了什么,我该如何阻止它?谢谢!

1 个答案:

答案 0 :(得分:0)

它工作正常我甚至在控制台中看不到什么错误:

  <!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="sweetalert.css">
</head>
<body>
<script src="sweetalert.min.js"></script>
<script type="text/javascript">
    window.alert = function (text) {
    swal({
        title: "Computer says:",
        text: text,
        timer: 3000,
        animation: "slide-from-top"
    });
    return true;
    };
    function run(input) {
    if (input[0] == "alert") {
        ta = input.slice(1, input.length);
        tap = ta.join(" ");
        alert(tap);
    }
}
run(["alert", "hello"]);
</script>
</body>
</html>