打开 Chrome 应用程序时,如何在 Chrome 网上应用店中的模态对话框中打开 url 链接。注意 shadow 中的背景 ramains 但它仍然是主页。并且 Chrome 网上应用店中的 URL 发生了变化。
最佳答案
对于对话框使用 jQuery UI
http://jqueryui.com/demos/dialog/#modal-message
要使用 JS 更改 URL,请使用 History API
同时检查 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/