jquery Ui对话框需要更改按钮单击事件

时间:2013-09-11 23:11:25

标签: javascript jquery html popupwindow

我正在使用jquery UI创建一个弹出窗口作为警报消息,我需要在单击调用并获取另一个页面时按下确定按钮 任何人都可以帮助我????

这是代码

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>jQuery UI Dialog - Modal message</title>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
        <!--<link rel="stylesheet" href="/resources/demos/style.css" />!-->

        <script>
            $(function() {
                $("#dialog-message").dialog({
                    modal : true,
                    buttons : {
                        enter : function() {
                            $(this).dialog("close");
                        }
                    }
                });
            });
        </script>
    </head>
    <body>
        <div id="dialog-message" title="WIN  PRICES" style="width:300px; height:150px;">
            <p>
                <!--<span class="ui-icon ui-icon-circle-check" style="float: left; margin: 0 7px 50px 0;"></span>!-->
                <span style ="float: left; margin:0 7px 50px 0;"><img src="b4l.jpg" width="77" height="53"></span>
                <h3>byu for less</h3>
                Shoping online <b>Need No Password</b>
                <br>
                Get your needs is our job.
            </p>
            <p>
                <b>every week win a price</b>.
            </p>
        </div>
        <p>
            Sed vel diam id libero <a href="http://example.com">rutrum convallis</a>. Donec aliquet leo vel magna. Phasellus rhoncus faucibus ante. Etiam bibendum, enim faucibus aliquet rhoncus, arcu felis ultricies neque, sit amet auctor elit eros a lectus.
        </p>
    </body>
</html>

2 个答案:

答案 0 :(得分:0)

您可以创建自定义提醒框,以便根据您的需要对其进行自定义。

a look here ,因为这有助于您选择更适合自己的方式。

PS:您也可以尝试下面的内容。

HTML

<input type="button" onclick="confirmation()" value="Want to go to google?">

JS

function confirmation() {
    var answer = confirm("Want to go to google?");
    if (answer){
        alert("Bye bye!");
        window.location = "http://www.google.com/";
    }
    else{
        alert("Thanks for sticking around!");
    }
}

答案 1 :(得分:0)

通过“致电并获取另一页”不确定您的意思 - 这会有效吗?

Working jsFiddle here

<html>
    <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
        <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />

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

                $( "#dialog-message" ).dialog({
                    modal: true,
                    buttons: {
                        enter: function() {
                            $( this ).dialog( "close" );
                            window.location.href='http://google.com';
                        }
                    }
                });

            }); //END $(document).ready()

        </script>
    </head>
<body>

    <div id="dialog-message">
        <h1>Example Dialog</h1>
        <img src="http://placehold.it/150x150" width="150" height="150"/>
        First Name: <input type="text" id="fname"><br />
        Last Name: <input type="text" id="lname"><br />
    </div>

</body>
</html>