[英]jQuery Mobile Force Reloading Page 'Error Loading Page'
I am using jquery for a small webapp and I've built in the option for the app to be available offline - to do so I force reload a page and if it has the correct parameters it uses a simple PHP $_GET to add the manifest line into the html tag, which then triggers the app cache. 我正在为小型Web应用程序使用jquery,并且我已经内置了该应用程序可以脱机使用的选项-为此,我强制重新加载页面,如果它具有正确的参数,它将使用简单的PHP $ _GET添加清单行插入html标记,然后触发应用程序缓存。
I have tried: 我努力了:
$.mobile.changePage
But it fails to trigger the appcache properly. 但是它无法正确触发appcache。 The only way I've been able to do it is to use:
我能够做到的唯一方法是使用:
window.location.href = window.location.href + "?appcache=true"
This works! 这可行! However I get an 'Error Loading Page' for a split second before the page reloads.
但是,在页面重新加载之前,我得到了一秒钟的“错误加载页面”。
Is there a way of either disabling this message or a different way of achieving the same outcome without the message? 有没有一种方法可以禁用此消息,或者以其他方式在没有该消息的情况下获得相同的结果?
Thank you. 谢谢。
您是否尝试过使用两个页面,例如: yourpage.php
和yourpageappcache.php
以及yourpageappcache.php
:
<?php header('Location: yourpage.php?appcache=true');?>
I managed to solve the issue by disabling ajax before jQuery mobile has loaded. 我设法通过在加载jQuery mobile之前禁用ajax来解决此问题。 As in this answer: How To Disable Ajax In jQuery Mobile Before Page Load?
如在此答案中: 如何在页面加载之前在jQuery Mobile中禁用Ajax?
So BEFORE jQuery mobile is called: 因此,在jQuery mobile之前被称为:
<script type="text/javascript" src="jquery"></script>
<script type="text/javascript">
$(document).bind("mobileinit", function () {
$.mobile.ajaxEnabled = false;
});
</script>
<script type="text/javascript" src="jquerymobile"></script>
This allows me to link to another page running the appcache (and with ajax enabled). 这使我可以链接到另一个运行应用程序缓存的页面(并启用了ajax)。
Thanks for your help. 谢谢你的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.