【问题标题】:onBackKeyDown get specific pageonBackKeyDown 获取特定页面
【发布时间】:2012-06-23 14:52:10
【问题描述】:

我想使用返回键@android 手机返回某个特定页面。 我的代码(JS):

function onBackKeyDown() {
    currentId = $.mobile.activePage.attr('id');
    if(currentId == "#swipediv"){
    $.mobile.changePage("#home", "slide", false, true);
    }
    else{
    history.go(-1);
    }
}

HTML:

<div data-role="page" data-theme="a" id="home">
      <div data-role="header"><h1>Test</h1></div>
        <div data-role="content">
          <p>Home</p>
        </div>

      </div>
    </div>

    <div id="swipediv">
        <div data-role="page" data-theme="a" id="1">
            <div data-role="header"><h1>1</h1></div>
            <div data-role="content">
                <p>1</p>
            </div>
         </div>
    </div>

怎么了?有什么建议吗?

最好的问候

【问题讨论】:

    标签: javascript jquery jquery-mobile cordova


    【解决方案1】:

    您是否像这样正确添加了后退按钮侦听器?

        function onDeviceReady() {
            // Register the event listener
            document.addEventListener("backbutton", onBackKeyDown, false);
        }
    

    如果是,那么您检查页面 ID currentId == "#swipediv" 应该在没有 # 的情况下使用 像这样

    currentId == "swipediv"
    

    【讨论】:

      猜你喜欢
      • 2015-08-24
      • 2012-09-23
      • 2013-07-25
      • 2014-11-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多