作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
在 jQuery Mobile 中:
<base href="">
页面中的标签相关代码:
// Test for dynamic-updating base tag support ( allows us to avoid href,src attr rewriting )
function baseTagTest() {
var fauxBase = location.protocol + "//" + location.host + location.pathname + "ui-dir/",
base = $("head base"),
fauxEle = null,
href = "",
link, rebase;
if (!base.length) {
base = fauxEle = $("<base>", { "href": fauxBase }).appendTo("head");
} else {
href = base.attr("href");
}
link = $("<a href='testurl' />").prependTo(fakeBody);
rebase = link[0].href;
base[0].href = href || location.pathname;
if (fauxEle) {
fauxEle.remove();
}
return rebase.indexOf(fauxBase) === 0;
}
最佳答案
base 元素是 jQuery Mobile 导航模型的关键组成部分,以至于当 jQuery Mobile 站点加载到无法动态更新 base 元素的浏览器中时,它会在 url 前面加上 base。
满足您需求的两个建议:
使用绝对文件路径而不是相对路径
使用 jQuery Mobile Download Builder并自定义 jQuery Mobile 应用程序所需的模块。我最初的猜测是您希望排除导航模块以移除基本元素功能。
关于javascript - 如何从 jQuery 移动脚本中删除基本标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15096031/
我是一名优秀的程序员,十分优秀!