在模态对话框中打开链接(如Chrome Web Store)


Open link in modal dialog (like Chrome Web Store)

当打开Chrome应用程序时,我如何在一个模态对话框中打开一个url链接,就像在Chrome Web Store上一样。注意背景仍然在阴影中,但它仍然是主页。和Chrome Web Store的URL变化

对于对话框使用jQuery UI

http://jqueryui.com/demos/dialog/modal-message

用JS修改URL使用历史API

http://html5demos.com/history

也检查良好的教程使用HTML5历史API (Pushstate?)

对于较旧的浏览器,您可能必须使用location。上面的jQuery UI站点就是一个很好的例子。

要打开对话框中的所有链接,您可以像下面这样编写代码

$('a').click(function(e){
  e.preventDefault();
  var url=$(this).attr('href')+"?content_only"; //content_only added to tell index.php to give only content without template and JS
   $.get(url, function(data) {
    $('.dialog').html(data).dialog();
   //change URL here
  });
});

要将所有url指向主页,您必须使用服务器端技巧,将所有url指向index.php。像example.com/index.php/subpage和检查文档准备,如果URL不只是index.php,我的意思是像example.com/index.php/subpage的东西,然后在对话框中打开example.com/index.php/subpage?content_only。在index.php中使用一个条件,content_only被指定,然后只返回subpage的内容,没有模板和JS。