我正在用jquery mobile構建一個網頁,並嘗試將頁面與參數鏈接起來。 這有效,但我的問題是,我無法鏈接到我目前留在不同的參數相同的頁面。使用不同參數鏈接到當前頁面jqm
例子:
<html>
<body>
<!-- START INDEX PAGE -->
<div data-role="page" id="index">
<div data-role="header">
<h1>Indexpage</h1>
</div>
<div data-role="content">
<a href="index.html#listpage?list=1">
<a href="index.html#listpage?list=2">
</div>
</div>
<!-- END INDEX PAGE -->
<!-- START LIST PAGE (page to list content i.e. user list)-->
<div data-role="page" id="listpage">
<div data-role="header>
<h1>Listpage</h1>
</div>
<div data-role="content">
<ul data-role="listview" id="listview">
</ul>
</div>
<script>
//to get passed parameter (list id)
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '= ([^&#]*)').exec(window.location.href);
if (results==null){
return null;
} else {
return results[1] || 0;
}
}
var list = $.urlParam('list');
switch(list) {
case 1:
//insert list one into page
break;
case 2:
//insert list two into page
break;
}
</script>
</div>
<!-- END LIST PAGE -->
</body>
</html>
所以,當我的列表2點擊IM停留在列表1時,它不會做任何事情。
感謝您的幫助
加上'相對= external'屬性錨塔赫,加載它沒有Ajax – Omar
相對=外部不起作用,因爲它與其他參數 –