我尝试创建一个系统,用户单击该链接,该链接将被加载到同一页面的弹出窗口中。例如;你有一个PHP链接像

<a href='user_message.php?hash=$hash'>$username</a>

如果用户单击该链接,是否有可能在同一页面的弹出窗口中加载该链接。请任何帮助将不胜感激。

我有能力
的PHP

echo"<a href='account.php?hash=$hash>connect</a>
<script type=text/javascript>
    $('a').click(function (e) {
e.preventDefault();
$('.boxes').fadeIn('slow').load('user_connect.php?hash=$hash');
});
</script>


我相信我在prevntDefault上具有a的事实不会使这项工作有效。
请这怎么可能

最佳答案

还没有测试过,但是应该很简单:

$(document).on('click', 'a', function(e){
   e.preventDeafult(); //don't let browser follow the link

   var href = $(this).attr('href'); //get the href from original link
   var options = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,width=500,height=500";
  //Now open the popup
  window.open(href, 'NameOfTheWindow', options);
})


请记住,此代码将覆盖您页面上所有链接的行为。如果只需要在弹出窗口中打开其中一些,则添加类并在处理程序中使用它。

     $(document).on('click', 'a.js-open-in-popup', func...

关于javascript - 是否有可能在弹出窗口中加载另一个php文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42140426/

10-09 17:59