单击jqueryui对话框中的链接

clicking a link in jqueryui dialog

本文关键字:链接 对话框 jqueryui 单击      更新时间:2023-11-18

我使用jquery对话框在模式对话框中显示html文件:

主站点调用test.html:

<body>
<div id="layer" style="display: none;">
</div>
</body>
<script type="text/javascript">
    $("#layer").dialog({
          dialogClass: 'noTitleStuff',
      autoOpen: false,
      position : ['center',20],
      /*draggable: false, */
      resizable : true,
      modal : true,
            show : 'fade',
            hide : /*'drop'*/'fade',
            width: 'auto',
            heigth: 'auto',
            open: function() {
             $(".ui-dialog-titlebar").removeClass('ui-widget-header');
      },
   });
  $( function() {
      $("#layer").load('test.php', function() {
          $("#layer").dialog("open");
      });
    });
</script>

这很好,test.php的内容显示得很好。但是,当我在test.php中单击链接时,整个浏览器窗口中都会打开该链接。如何在对话框中显示新网站?

感谢您的帮助

将新url的内容加载到对话框中。

$(function(){
    $(document).on("click", ".yourLinkCssClassName", function (e) {
        e.preventDefault();
        $.get($(this).attr("href"), function (data) {
            $("#layer").html(data);
        });
    });
});