4

在 jQuery Mobile 中:

  • 如何<base href="">从页面中删除标签
  • 如何禁用基本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;
 }
4

1 回答 1

0

基本元素是 jQuery mobile 导航模型的关键组成部分,以至于当 jQuery mobile 网站加载到无法动态更新基本元素的浏览器中时,它会在 url 前面加上基本元素。

满足您需求的两个建议:

  1. 使用绝对文件路径而不是相对路径

  2. 使用jQuery Mobile 下载构建器并自定义 jQuery Mobile 应用程序所需的模块。我最初的猜测是您可能希望排除导航模块以删除基本元素功能。

于 2013-03-04T22:49:25.233 回答