定时延迟自动页面重定向 JQuery 移动

Timed delayed auto page redirect JQuery Mobile

您好,我正在尝试让一个页面自动重定向到 JQM 多页索引中的另一个页面。我还希望重定向延迟大约 3 秒。所以基本上我想要#behavior-summary(显示 3 秒)并自动返回#order-summary 而无需单击。我知道可能有一个简单的解决方案。我在这里尝试了很多答案,但似乎没有用。我在用 JQ 2.1.4 和 JQM 1.4.5.

另一方面,这不是启动画面,而是一个 .gif,在用户输入项目后显示动画确认。现在我只是使用一个按钮,正如您在#behavior-summary 上看到的那样。目标是能够在指定的时间段后删除,没有按钮直接重定向。

以下是我尝试过但由于某种原因不起作用的一些解决方案:

Example 1

Example 2

如果有人能提供帮助,我将不胜感激

<div data-role="page" id="order-summary">
   <div data-role="header">
        <h1>Record Drink</h1>
        <a href="#nav-panel" data-icon="bars" data-iconpos="notext">Menu</a>
   </div>
   <div data-role="content" id="summary-img">
        <img src="img/behavior_4.png"/>
        <a href="#behavior-summary" class="ui-btn ui-corner-all ui-btn-a" >Save</a>
   </div>
</div>    


<div data-role="page" id="behavior-summary">
    <div data-role="header" id="record-header">
        <h1>Record Drink</h1>
        <a href="#nav-panel" data-icon="bars" data-iconpos="notext">Menu</a>
    </div><!-- /header -->
    <div data-role="content" id="summary-img">
        <img src="img/drink_1.gif"/>
        <a href="#order-summary" class="ui-btn ui-corner-all ui-btn-a" >Save</a>
    </div>
</div>

提前致谢!

actual have not understand your whole Q, but if you are looking for a redirect then you can use a window.location.href = '#pagname or string'; or if you want to stop the setInterval then you can use clearInterval function

Please let me know if i can help you or i help understand the your pro

你可以使用behavior-summary的pageshow事件,然后一个3秒延迟的setTimeout和一个pagecontainer change方法回到第一页:

$(document).on("pageshow","#behavior-summary", function(){ 
  setTimeout(function(){
    $(":mobile-pagecontainer").pagecontainer( "change", "#order-summary", {} );
  }, 3000);
}); 

DEMO

如果您更喜欢 pagecontainer 事件:

$(document).on( "pagecontainershow", function( event, ui ) {
  if (ui.toPage.prop("id") == "behavior-summary" ){
    setTimeout(function(){
      $(":mobile-pagecontainer").pagecontainer( "change", "#order-summary", {  } );
    }, 3000);  
  }
});