在父窗口之外的任何位置移动jQuery对话框弹出窗口

时间:2013-04-08 22:03:57

标签: jquery jquery-ui-dialog

我已完成jQuery UI Dialog弹出窗口,我现在唯一的问题是我无法将其移出包含窗口。我希望能够移动此对话框弹出窗口,就像您使用javascript的window.open方法创建的窗口一样(可以在屏幕中的任何位置移动)

任何建议或想法?我已经尝试过收容财产购买仍然没有超出父屏幕。


代码:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0  Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />  
    <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script> 
    <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" type="text/javascript"></script>  
    <script type="text/javascript">
         $(document).ready(function (){
                $('#dialog').dialog({ draggable: true, resizeable: true, dialogClass: 'main-dialog-class', 
                title: 'Definition', width: 800, height: 600, autoOpen: false, show: { effect: "clip", duration: 1000 },
                    hide: { effect: "explode", duration: 1000}
                })

                $(".opener").click(function () {   $('#dialog').dialog("open"); return false; });

                if (!$.ui.dialog.prototype._makeDraggableBase) {
                    $.ui.dialog.prototype._makeDraggableBase = $.ui.dialog.prototype._makeDraggable;
                    $.ui.dialog.prototype._makeDraggable = function () {
                        this._makeDraggableBase();
                        this.uiDialog.draggable("option", "containment", false);
                    };
                }
            });
    </script>
</head>
<body>
 <div id="dialog" title="Report Definition" style="width:800px; height:800px; overflow:scroll;">  
 <p>This is an animated dialog which is useful for displaying information </p>
 </div> 
<a href="#" class="opener" > click </a>

</body>
</html>

1 个答案:

答案 0 :(得分:1)

你不能用jQuery对话框,句点来做这件事。 jQuery对话框只是一个HTML标记,它是页面的一部分。

据我所知,唯一的选择是使用window.open。您可以使用window.open所需的任何HTML,并且几乎可以完全控制窗口(在某种程度上)。