嗨,我有两个 html 文件 index.html 和 test.html 在这两个文件中我都添加了后退按钮,因为data-rel="back"
当我从 index 转到 test 时,然后在 test.html 上单击后退按钮,然后它不会导航到 index.html 。我的索引文件如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.1.0.css" />
<link rel="stylesheet" href="docs/assets/css/jqm-docs.css" />
<link rel="stylesheet" href="docsdemos-style-override.css" />
<script type="text/javascript" src="jquery.mobile/jquery-1.7.2.min"></script>
<script type="text/javascript" src="jquery.mobile/jquery.mobile-1.1.0.js"></script>
</head>
<body>
<div id="searchpage" data-role="page" data-theme="b" data-role="content" data-add-back-btn="true">
<div data-role="header" align="center">
<a href="#" data-rel="back" data-icon="arrow-l">Back</a>
<h1>index page</h1>
<a href="MainMenu.html" data-icon="grid">Menu</a>
</div>
<div data-role="fieldcontain" class="ui-field-contain ui-body ui-br" >
<input type="text" name="stock" id="enterstock" value="" />
<input type="submit" id = "verify" data-role="button">
</div>
<script type="text/javascript">
$("#verify").click(function (e)
{
e.stopImmediatePropagation();
e.preventDefault();
window.location = "Test.html";
//$.mobile.changePage('Test.html')
});
</script>
</div>
</body>
</html>
我的 test.html 是:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.1.0.css" />
<link rel="stylesheet" href="docs/assets/css/jqm-docs.css" />
<link rel="stylesheet" href="docsdemos-style-override.css" />
<script type="text/javascript" src="jquery.mobile/jquery-1.7.2.min"></script>
<script type="text/javascript" src="jquery.mobile/jquery.mobile-1.1.0.js"></script>
<!-- Uncomment following line to access PhoneGap APIs (not necessary to use PhoneGap to package web app) -->
<!-- <script type="text/javascript" charset="utf-8" src="cordova-1.6.1.js"></script>-->
</head>
<body>
<div id="cash" data-role="page" data-theme="a" data-role="content" data-add-back-btn="true">
<div data-role="header" align="center">
<a href="#" data-rel="back" data-icon="arrow-l">Back</a>
<h1>Test page</h1>
<a href="MainMenu.html" data-icon="grid">Menu</a>
</div>
<h1>Testing</h1>
</div>
</body>
</html>
如果我使用$.mobile.changePage('Test.html')
后退按钮可以正常工作,但window.location = "Test.html";
无法正常工作。为什么会这样?在 blackberry5 changePage 中不起作用,因此我无法使用它。任何建议将不胜感激。提前致谢