1

嗨,我使用了从一个页面导航到另一个页面$.mobile.changePage('test.html');。这在 android、symbian 和 blackberry6+ 中运行良好。但我也希望我的应用程序在 blackberry5 上运行。Blackberry5 不支持 ajax,因此$.mobile.changePage('test.html');不适用于它。

出于这个原因,我使用window.open("test.html");and window.location.href = "test.html"; Here 它在所有平台上都能完美运行,包括 blackberry4.6+。但现在问题是我在 test.html 中有标题:

     <div data-role="header" align="center">

        <a href="#" data-rel="back" data-icon="arrow-l">Back</a>
            <h1>Test.html</h1>
        <a href="MainMenu.html"  data-icon="grid">Menu</a>


    </div>

但是现在后退按钮不起作用。如果我$.mobile.changePage('test.html');用于导航,则后退按钮可以正常工作,但不能使用window.open("test.html");and window.location.href = "test.html";

因此,我使用会话并在单击后退按钮时强行调用页面。作为:

<script type="application/javascript">

            function redirect(url)
            {
                alert("inside redirect:"+url);
                window.location = url;
            }

        </script>

        <div data-role="navbar">
            <ul>

                <li> <a onclick="redirect( getCookie('paged'))" data-icon="back" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Back</a></li>
                <li> <a onclick="redirect(getCookie('paged'))" data-icon="back" data-iconpos="notext" data-direction="reverse" class="ui-btn-left jqm-home">Back</a></li>

            </ul>
        </div>

现在,后退按钮也可以正常工作,但是当我单击硬件后退按钮时,它会再次转到之前的页面。

我如何在$.mobile.changePage(...)没有 ajax 的情况下使用,所以我可以将它用于包括 blackberry4.6+ 在内的所有平台

任何建议将不胜感激。提前致谢。

4

4 回答 4

1

我尝试使用全局配置禁用 ajax,但由于某种原因它对我来说不起作用。

我尝试如下,它有效

window.location.href="myfile.html";
于 2013-04-24T06:59:06.990 回答
0

您可以使用此功能。

$.mobile.changePage('#gototestpage');

但是有一些限制。您必须像这样将代码保留在另一个 div 中的同一页面中,

<div id="gototestpage"> --- Your Code here ----- </div>
于 2012-07-25T11:59:58.683 回答
0

您是否尝试将全局属性设置$.mobile.ajaxEnabledfalse?请参阅http://jquerymobile.com/demos/1.1.1/docs/api/globalconfig.html。据说“jQuery Mobile 将尽可能通过 Ajax 自动处理链接点击和表单提交”。我现在不确定它是否也会影响$.mobile.changePage,但也许值得一试......

于 2012-07-25T06:27:16.867 回答
0

我已经尝试了这两种解决方案,都对我有用:

window.location.href = yourpageurl;

或者

$.mobile.ajaxEnabled = false;
$(":mobile-pagecontainer").pagecontainer( "change", yourpageurl);
于 2017-02-16T14:34:56.247 回答