函数调用ok单击按钮

时间:2015-01-07 08:10:58

标签: jquery asp.net-mvc

以下是我的代码。出现模态弹出窗口。当我点击ok时,用户应该重定向到动作方法。我怎样才能做到这一点。请帮忙。

<script type="text/javascript">
        debugger;
        $(document).ready(function () {

            debugger;
            $("#dialog").dialog({
                title: "Alert!",
                buttons: {
                    Ok: function () {
                        $(this).dialog('ok');
                    }
                }
            });

        });
    </script>

2 个答案:

答案 0 :(得分:1)

您可以像这样使用window.location.href

$("#dialog").dialog({
    title: "Alert!",
    buttons: {
        Ok: function() {
            window.location.href = " put your url "
        }
    }
});

答案 1 :(得分:0)

您可以在ok按钮响应功能中使用window.location.hrefwindow.location.replace

$("#dialog").dialog({
    title: "Alert!",
    buttons: {
        Ok: function() {
           window.location.replace("http://stackoverflow.com");
           return false;
        }
    }
});