这是一个相当简单的实现。
应使用 changePage 函数(jQuery Mobile 1.4 及更低版本)或 pageContainer 更改(jQuery Mobile 1.4 及更高版本)以编程方式处理页面更改。
解决方案:
$.mobile.changePage("second.html", { transition: "slideup", changeHash: false });
您需要将 changeHash 设置为 false。
示例:
index.html
<!DOCTYPE html>
<html>
<head>
<title>jQM Complex Demo</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" />
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<script>
$(document).on('pagebeforeshow', '#index', function(){
$(document).on('click', '#open-page', function(){
alert('sdfsd');
$.mobile.changePage("second.html", { transition: "slideup", changeHash: false });
});
});
</script>
</head>
<body>
<div data-role="page" id="index" data-theme="a" >
<div data-role="header">
<h3>
First Page
</h3>
<a class="ui-btn-right" id="open-page">Next</a>
</div>
<div data-role="content">
</div>
<div data-role="footer" data-position="fixed">
</div>
</div>
</body>
</html>
second.html
<div data-role="page" id="second" data-theme="a" >
<div data-role="header">
<h3>
Second Page
</h3>
<a href="#index" class="ui-btn-left">Back</a>
</div>
<div data-role="content">
</div>
<div data-role="footer" data-position="fixed">
</div>
</div>
更新:
您需要的信息与 jQuery Mobile 无关。
我向您展示了一个 jQuery Mobile 可以实际执行的解决方案。但此解决方案将永久显示原始 HTML 文件名。这是因为初始 HTML 页面被加载到 DOM 中,并且所有其他页面都被加载到其中。因此,jQuery Mobile 可以完全控制链接名称。
但这不是提到的页面使用的。它正在使用某种重写引擎。默认情况下,重写引擎将 URL 映射到文件系统路径。但是,它也可用于将一个 URL 重定向到另一个 URL(在此处完成),或调用内部代理获取。他们可能正在使用开启了 mod_rewrite 模块的 Apache Web 服务器。