jquery、jquery mobile浏览器后退按钮问题

发布于 2024-12-12 11:24:23 字数 359 浏览 5 评论 0原文

这是我的 jquery 移动页面的自动页面转换问题。请提供任何帮助。

我在页面 A,单击链接,然后转到页面“B”。现在,我单击页面“B”中的链接转到页面 C。

在页面 CI 上,单击浏览器后退按钮(iPhone 位于左下角),它会根据需要将我带到页面 B。现在,我单击同一链接返回到页面 C。这一次,浏览器会闪烁页面“C”,但是很快就会自动加载页面“(jquery mobile 加载图像在中间,它会进行过渡幻灯片)” B”代替。当我查看顶部的 URL 时,我仍然是 pageC.html url,而不是 B。只有内容是 Page B 的。

我这样做有意义吗?怎么了?请帮助我。

更多信息:我在使用什么?

非常感谢

Here is an automatic page transtion issue I've with my jquery mobile page. Any help is appreciated please.

I am on page A, I click on a link, then I go to page "B". Now I click on a link in Page "B" to go to Page C.

On Page C I click browser back button (iphone at the bottom left) it takes me to page B as desired good. Now, I click on the same link to go back to Page C. This time, the browser flashes the Page "C" however, soon automatically (with the jquery mobile loading image in the middle it does a transition slide) it loads Page "B" instead. When I look at the URL on the top, I still pageC.html url and not B. only the content is of Page B.

Do I make sense? What is happening? Help me please.

More info: what am I using?

Thanks much

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

巨坚强 2024-12-19 11:24:23

我遇到了同样的问题,并通过将 hashListeningEnabled 设置为 false 来解决它。

$.extend(  $.mobile , {
    ajaxEnabled      : false,
    hashListeningEnabled: false
});

I ran into the same issue and was able to solve it by setting hashListeningEnabled to false.

$.extend(  $.mobile , {
    ajaxEnabled      : false,
    hashListeningEnabled: false
});
情深已缘浅 2024-12-19 11:24:23

$.extend( $.mobile , {
ajax启用:假,
哈希监听启用:假
});

这对我也有用。在 iPhone 5s 上,我会浏览到一个页面(使用 .pagecontainer("change") 方法)。该页面是在客户端代码中动态生成的,因此它不是实际的 URL。无论如何,我第一次使用后退按钮时,它会起作用。第二次我导航到不同的页面时,会发生转换,然后页面会快速刷新/重新加载。此后,后退按钮停止工作。

在标签中实现此代码对我有用。请确保将其放在 jquery 引用之后,但在 jquery MOBILE 引用之前。这真是令人沮丧的陷阱。我的标签如下所示:

    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
    $(document).bind("mobileinit", function () {
        $.mobile.ajaxEnabled = false;
        $.mobile.pushStateEnabled = false;
    });
</script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src="phonebook.js"></script>

$.extend( $.mobile , {
ajaxEnabled : false,
hashListeningEnabled: false
});

this also worked for me. On iPhone 5s, I would browse to a page (using the .pagecontainer("change") method). The page was dynamically generated in client code, so it wasn't an actual URL. Anyway, the first time I used the back button, it would work. The second time I navigated to a different page, the transition would happen, and then the page would do a quick flash/reload. After that, the back button stopped working.

Implementing this code in the tag worked for me. MAKE SURE you put this AFTER your jquery reference, but BEFORE your jquery MOBILE reference. This is a really frustrating Gotcha. My tag looks like this:

    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
    $(document).bind("mobileinit", function () {
        $.mobile.ajaxEnabled = false;
        $.mobile.pushStateEnabled = false;
    });
</script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src="phonebook.js"></script>
枕头说它不想醒 2024-12-19 11:24:23

兄弟,

我猜问题出在你的文件结构上。
您正在使用 jquery 移动库,但同时您正在使用两个页面进行转换,但这是行不通的。

Buddy,

I guess Issue is with your file structure.
You are using jquery mobile library but at the same time you are working with two pages to have transitions which won't work.

七度光 2024-12-19 11:24:23

我也有类似的问题。将 data-ajax="false" 添加到链接有时会有所帮助。

例如,更改

`<a href="#" data-role="button" id="fix_link">Another Page</a>`

TO

`<a data-ajax="false" href="#" data-role="button" id="fix_link">Another Page</a>`

有很多地方可以阅读有关 JQuery Mobile 如何加载页面和使用导航的信息,但我通过修改此内容学到了最多,有时 data-rel="external" 是某些情况。

I have had a similar issue. Adding data-ajax="false" to the link sometimes helps.

For example change

`<a href="#" data-role="button" id="fix_link">Another Page</a>`

TO

`<a data-ajax="false" href="#" data-role="button" id="fix_link">Another Page</a>`

There are many places to read about how JQuery Mobile loads pages and works with navigation but I learned the most by tinkering around with this and sometimes data-rel="external" is certain cases.

一杯敬自由 2024-12-19 11:24:23

如果您不使用 AJAX 导航(即您将选项 $.mobile.ajaxEnabled 设置为 false),JQuery Mobile 建议同时禁用 $.mobile.pushStateEnabled 来修复这些浏览器问题:

注意:在构建全局禁用 Ajax 导航系统或在单个链接上频繁禁用 Ajax 导航系统的 jQuery Mobile 应用程序时,我们建议禁用 $.mobile.pushStateEnabled 全局配置选项,以避免某些浏览器中的导航行为不一致。

http://demos.jquerymobile.com/1.4.2/navigation-linking-页面/

要禁用它:

$(document).bind("mobileinit", function () {
  $.mobile.ajaxEnabled = false;
  $.mobile.pushStateEnabled = false;
});

If you are not using AJAX navigation (i.e. you have the option $.mobile.ajaxEnabled set to false), JQuery Mobile recommends to also disable $.mobile.pushStateEnabled to fix those browser issues:

Note: When building a jQuery Mobile application where the Ajax navigation system is disabled globally or frequently disabled on individual links, we recommend disabling the $.mobile.pushStateEnabled global configuration option to avoid inconsistent navigation behavior in some browsers.

http://demos.jquerymobile.com/1.4.2/navigation-linking-pages/

To disable it:

$(document).bind("mobileinit", function () {
  $.mobile.ajaxEnabled = false;
  $.mobile.pushStateEnabled = false;
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文