如何在"关闭"在jAlert中按下按钮

时间:2016-07-08 11:56:40

标签: javascript

我试图在用户提供错误的身份验证凭据时重新定向页面但是在jAlert弹出之后并且正好在按下jAlert的关闭btn之后但是我无法这样做。请帮我完成这项任务。在此先感谢!!!

以下是代码:

<script>
$(document).ready(function () {

      $.jAlert({
                 'title': 'Authentication Error',
                 'content': 'Invalid Username of Password"!',
                 'theme': 'blue',
                 'btns': { 'text': 'close' }
                });
           });
</script>

1 个答案:

答案 0 :(得分:1)

jAlert插件提供onClose函数,在模式被解除时触发。在函数中定义所需的行为,例如:

<script>
    $(document).ready(function() {
       $.jAlert({
             'title': 'Authentication Error',
             'content': 'Invalid Username or Password!',
             'theme': 'blue',
             'btns': { 'text': 'close' },
             'onClose': function(alertElem) {
                 // alert("Redirecting...");
                 window.location = "index.html";
             }
        });
   });
</script>

请参阅http://flwebsites.biz/jAlert/上的jAlert文档。