Transfer page via Javascript
Description
The following code shows how to transfer page via Javascript.
Example
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type="text/javascript"
src="http://code.jquery.com/mobile/1.3.0-beta.1/jquery.mobile-1.3.0-beta.1.js"></script>
<link rel="stylesheet" type="text/css"
href="http://code.jquery.com/mobile/1.3.0-beta.1/jquery.mobile-1.3.0-beta.1.css">
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){<!--from ww w . j av a 2 s .c o m-->
$(document).on('vclick', '[data-rel=back]', function (e) {
e.stopImmediatePropagation();
e.preventDefault();
console.log('back');
var back = $.mobile.activePage.prev('[data-role=page]');
$.mobile.changePage(back, {
transition: 'slide',
reverse: true
});
});
});//]]>
</script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>My Header page 1</h1>
</div>
<a href='#p1' data-role="button">page 2</a>
</div>
<div data-role="page" data-add-back-btn="true"
data-back-btn-text="Previous" id='p1'>
<div data-role="header">
<h1>My Header page 2</h1>
</div>
</div>
</body>
</html>