JQuery对话框在IE中不起作用

时间:2013-10-01 08:32:56

标签: javascript jquery

为什么此代码在IE中不起作用?我该怎么做才能让它正常工作? 以下代码在Firefox,Chrome和Opera中生成预期的jQueryUI模式弹出对话框。但是,它在Internet Explorer中失败。

   <!DOCTYPE html>
<html>
    <head>
     <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> 
    </head>

    <body>
        <script language="JavaScript">
        $(document).ready(function() {
            console.log( "ready!" );

                $("#link1").on("click", function(e) {
                    var link = this;

                    e.preventDefault();

                    $("<div>Are you sure you want to continue?</div>").dialog({
                        buttons: {
                            "Ok": function() {
                                window.location = link.href;
                            },
                            "Cancel": function() {
                                $(this).dialog("close");
                            }
                        }
                    });
                }); 
        });         
        </script>

        <a id="link1" href=http://google.com>test link</a>

    </body>
</html>

1 个答案:

答案 0 :(得分:0)

试 window.location.assign(link.href)

相关问题