JQTouch.js 会干扰链接吗?
我正在使用 Jonathan Stark 的书中有关使用 HTML、CSS 和 Javascript 构建手机应用程序的数据库代码。在他的 HTML 页面上,他引用了 jquery、jqtouch 和 javascript。
在 HTML 页面上,他创建了转到同一页面的简单链接:
<li class="arrow"><a id="1" href="#date">Yesterday</a></li>
当我将其替换为...
<li><a href="rc18.html"><strong>RC18 setups</strong></a></li>
...则该页面仍然存在;它不会更改为新的 HTML 页面。
那么,JQTouch.js 会干扰链接吗?
Jqtouch.js 有 9 个对“href”的引用,但我不知道足够的 Javascript 来理解它们。
这是一个例子:
function showPageByHref(href, options) {
var defaults = {
data: null,
method: 'GET',
animation: null,
callback: null,
$referrer: null
};
var settings = $.extend({}, defaults, options);
if (href != '#')
{
$.ajax({
url: href,
data: settings.data,
type: settings.method,
success: function (data, textStatus) {
var firstPage = insertPages(data, settings.animation);
if (firstPage)
{
if (settings.method == 'GET' && jQTSettings.cacheGetRequests && settings.$referrer)
{
settings.$referrer.attr('href', '#' + firstPage.attr('id'));
}
if (settings.callback) {
settings.callback(true);
}
}
},
error: function (data) {
if (settings.$referrer) settings.$referrer.unselect();
if (settings.callback) {
settings.callback(false);
}
}
});
}
else if ($referrer)
{
$referrer.unselect();
}
}
这里:
// User clicked an internal link, fullscreen mode
if (target == '_webapp') {
window.location = $el.attr('href');
}
// User clicked a back button
else if ($el.is(jQTSettings.backSelector)) {
goBack(hash);
}
// Branch on internal or external href
else if (hash && hash!='#') {
$el.addClass('active');
goTo($(hash).data('referrer', $el), animation);
} else {
$el.addClass('loading active');
showPageByHref($el.attr('href'), {
animation: animation,
callback: function(){
$el.removeClass('loading'); setTimeout($.fn.unselect, 250, $el);
},
$referrer: $el
});
他还引用了 jquery.js,并且那里的 href 实例对我来说非常神秘。您能通过上面的代码看到是否有什么东西干扰我进入应用程序同一文件夹中的另一个 html 页面。
I am using the database code in Jonathan Stark's book on using HTML, CSS, and Javascript to build phone apps. On his HTML page, he references jquery, jqtouch, and javascript.
On the HTML page, he creates simple links that go to the same page:
<li class="arrow"><a id="1" href="#date">Yesterday</a></li>
When I replace that with...
<li><a href="rc18.html"><strong>RC18 setups</strong></a></li>
...then the page remains; it doesn't change to the new HTML page.
So, can JQTouch.js interfere with links?
Jqtouch.js has 9 references to 'href,' but I don't know enough Javascript to understand them.
Here's an example:
function showPageByHref(href, options) {
var defaults = {
data: null,
method: 'GET',
animation: null,
callback: null,
$referrer: null
};
var settings = $.extend({}, defaults, options);
if (href != '#')
{
$.ajax({
url: href,
data: settings.data,
type: settings.method,
success: function (data, textStatus) {
var firstPage = insertPages(data, settings.animation);
if (firstPage)
{
if (settings.method == 'GET' && jQTSettings.cacheGetRequests && settings.$referrer)
{
settings.$referrer.attr('href', '#' + firstPage.attr('id'));
}
if (settings.callback) {
settings.callback(true);
}
}
},
error: function (data) {
if (settings.$referrer) settings.$referrer.unselect();
if (settings.callback) {
settings.callback(false);
}
}
});
}
else if ($referrer)
{
$referrer.unselect();
}
}
and here:
// User clicked an internal link, fullscreen mode
if (target == '_webapp') {
window.location = $el.attr('href');
}
// User clicked a back button
else if ($el.is(jQTSettings.backSelector)) {
goBack(hash);
}
// Branch on internal or external href
else if (hash && hash!='#') {
$el.addClass('active');
goTo($(hash).data('referrer', $el), animation);
} else {
$el.addClass('loading active');
showPageByHref($el.attr('href'), {
animation: animation,
callback: function(){
$el.removeClass('loading'); setTimeout($.fn.unselect, 250, $el);
},
$referrer: $el
});
He also references jquery.js, and the href instances there are extremely cryptic to me. Can you see by the code above if something is interfering with me going to another html page in the same folder of the app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
rel="external"
放在您的链接上,如下所示:jQTouch 应该保留它。
Put
rel="external"
on your link, like this:jQTouch should leave it alone then.