php - 在模态对话框中打开链接(如 Chrome 网上应用店)

标签 php javascript jquery dialog modal-dialog

打开 Chrome 应用程序时,如何在 Chrome 网上应用店中的模态对话框中打开 url 链接。注意 shadow 中的背景 ramains 但它仍然是主页。并且 Chrome 网上应用店中的 URL 发生了变化。

最佳答案

对于对话框使用 jQuery UI

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

要使用 JS 更改 URL,请使用 History API

http://html5demos.com/history

同时检查 Good tutorial for using HTML5 History API (Pushstate?)

对于较旧的浏览器,您可能必须使用 location.hash ,上面的 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 并检查 Document ready 是否 URL 不仅仅是 index.php 我的意思是像 example.com/index.php/subpage 然后在对话框中打开 example.com/index.php/subpage?content_only。在 index.php 中使用一个条件,指定 content_only 然后只返回 subpage 的内容,没有模板和 JS。

关于php - 在模态对话框中打开链接(如 Chrome 网上应用店),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8635418/

相关文章:

javascript - 使用 JS 将类应用于父元素

javascript - $.get 并获取值(value)

php - 将数据从 PHP 传递到 JavaScript

php - 如何在 system() 中退出 shell 模式

javascript - 为什么我必须点击这个输入按钮两次才能调用一个函数?

javascript - 一次运行所有过去的作业

javascript - 聚焦元素时,页面不会在 Firefox 和 IE 中滚动?

php - 即使没有成功,Ajax 成功功能仍然有效

php - 使用 PHP 逻辑的动态表格布局

php - 如何在同一查询中两次列出数据库行?