如何在jAlert中按下“关闭”按钮时启用功能

How to enable a function when "close" button is pressed in jAlert

本文关键字:关闭 按钮 功能 启用 jAlert      更新时间:2023-09-26

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


这是代码:

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

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 文档。