Get active page id

Description

The following code shows how to get active page id.

Example


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-git.js'></script>
<script type='text/javascript'
  src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
<link rel="stylesheet" type="text/css"
  href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css">
<script type='text/javascript'>
$(window).load(function(){<!--from   www. j a va 2 s  .  co m-->
    $(window).on('pageshow', function() {
       if($.mobile.activePage.attr("id") === "intro"){
            setTimeout(function() {
                console.log($.mobile.activePage.attr("id"));
                $.mobile.changePage('yourURL#home');
            }, 2000);
        }
    });
});
</script>
</head>
<body>
  <div data-role="page" id="intro">
    <p>Intro page</p>
  </div>
  <div data-role="page" id="home">
    <p>Home page</p>
  </div>
</body>
</html>

Click to view the demo





















Home »
  jQuery Mobile »
    Example »




Button
Button Event
Button Icon
Button Text
Checkbox
Collapsible
Date
Dialog
Event
Footer
Form
Header
Icon
Input
Layout
Listview
Listview Divider
Listview Item
Loader
mobile_settings
Navbar
Page
Page Event
Popup
Radio
Select
Slider
Switch
Textarea
Theme