gpt4 book ai didi

javascript - 如何从 jQuery 移动脚本中删除基本标记?

转载 作者:搜寻专家 更新时间:2023-10-31 21:51:00 26 4
gpt4 key购买 nike

在 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;
}

最佳答案

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

满足您需求的两个建议:

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

  2. 使用 jQuery Mobile Download Builder并自定义 jQuery Mobile 应用程序所需的模块。我最初的猜测是您希望排除导航模块以移除基本元素功能。

关于javascript - 如何从 jQuery 移动脚本中删除基本标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15096031/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com