【发布时间】:2012-04-04 16:23:48
【问题描述】:
这个问题已经讨论过好几次了,但我还没有看到一个具体的答案。
类似/相同的问题:SO question
假设我有index.html:
<div id="index1" data-role="page">
<div data-role="header"><h1>Index 1</h1></div>
<div data-role="content"></div>
<div data-role="footer">
<a data-role="button" id="toshop2">
To Shop 2
</a>
</div>
</div>
和shop.html:
<div id="shop1" data-role="page">
<div data-role="header"><h1>Shop 1</h1></div>
<div data-role="content"></div>
<div data-role="footer">
<a data-role="button" href="#shop2">To Shop 2</a>
<a data-role="button" href="index.html" rel="external">
To Index
</a>
</div>
</div>
<div id="shop2" data-role="page">
<div data-role="header"><h1>Shop 2</h1></div>
<div data-role="content"></div>
<div data-role="footer">
<a data-role="button" href="#shop1">To Shop 1</a>
<a data-role="button" href="index.html" rel="external">
To Index
</a>
</div>
</div>
我想做类似的事情:
$('#toshop2').on('click', function() {
$.mobile.changePage("shop.html#shop2");
});
我们现在都知道,这是行不通的。它会抓取第一个 DOM 页面(shop.html 中的#shop1 并将其附加到index.html DOM 中。
我知道这样的傻事:
$('#toshop2').on('click', function() {
window.open('shop.html#shop2', '_parent');
});
会起作用(是的,不会有过渡)。
问题是(假设没有其他解决方案,只能破解):
- 我可以/应该以不同的方式破解它吗?
- 我还能以某种方式过渡到外部页面吗?
【问题讨论】:
标签: javascript jquery-mobile navigation