gpt4 book ai didi

javascript - PhoneGap 在 HTML 中加载本地页面

转载 作者:行者123 更新时间:2023-12-01 05:36:21 24 4
gpt4 key购买 nike

我尝试使用 Jquery .load() 在我的 phonegape 应用程序 中加载页面,但它不起作用,因为它不在服务器上而是在本地计算机上。当我在构建时上传应用程序时。 phonegape 我的页面仍将包含在 www 文件夹中。如何在 div 中加载页面?这不起作用

<script>

$(".form-control2").change(function(){


$(".plan_mese4").load("select_mese.html");

});
</script>

如果我使用 http 它可以工作,但我不需要它,因为我的文件是本地的而不是在服务器上。

编辑*

现在我的应用程序在桌面上,我还使用phonegap和.load()编译了它,因为文件是本地的,所以它不起作用。仅当我将文件放在服务器上并从那里加载它时它才有效,但我不希望这样做,因为请求需要更多时间。

最佳答案

感谢 Quentin,我发现我可以使用文件路径进行 ajax 调用,即使它是本地的。所以如果其他人需要的话我就这样做了。我在我的案例中获取了网址位置 file:///E:/​​rezerv.city/www/local.html?id=114&tip=5 并删除了 local.html?id =114&tip=5.html 部分,我在我的例子中添加了我需要的 select_mese.html。

$(".form-control2").change(function(){

var url =window.location.href;
url = url.substring(0, url.lastIndexOf("/") + 1);
$(".plan_mese4").load(url +'index.html');


});

关于javascript - PhoneGap 在 HTML 中加载本地页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33800933/

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