jQuery Mobile get current page

后端 未结 8 1320
孤城傲影
孤城傲影 2021-02-04 01:44

I am using jQuery Mobile 1.1.1 and Apache Cordova 2.0.0. I want my app to exit when I press back button but only if current page have ID = feedZive. I am using following code to

相关标签:
8条回答
  • 2021-02-04 02:46

    I realise this is an old thread, so this is probably a more recent addition.

    Have you tried:

    var activePage = $.mobile.pageContainer.pagecontainer("getActivePage");
    if(activepage[0].id == yourpageid)
    { /*do something here*/ }
    

    or another way:

    var activePage = $.mobile.activePage.attr('id')
    if(activepage == yourpageid)
    { /*do something here*/ }
    
    0 讨论(0)
  • 2021-02-04 02:48

    Try using

    var activePage = $.mobile.activePage.attr("id");
    

    I made a working jsfiddle for you http://jsfiddle.net/Z5Uze/1/

    0 讨论(0)
提交回复
热议问题