好的,浏览问题我找到了将外部页面加载到phonegap View 中的正确方法(即不丢失 session 或打开设备浏览器),如下所述:How can I load a webpage inside the phonegap webview? 在这里:PhoneGap for iPhone: problem loading external URL
下一步是:在我打开外部页面(它归我所有,我可以修改它)后,我如何返回到我的本地应用程序?假设我在外部页面中有一个链接,并且我希望用户在单击时重定向回 PhoneGap 应用程序内的本地 html 页面 (mypage.html)。
链接的 href 属性应该有什么 url?我尝试将其设置为“file:///android_asset/www/mypage.html”但不起作用
最佳答案
您想要使用ChildBrowser打开外部网页的插件。然后您需要将 ChildBrowser.onLocationChange 属性设置为您自己的函数。然后,当用户离开远程页面时,您将收到位置更改的通知,以便您可以关闭 ChildBrowser 并导航到新的本地页面。您甚至不需要触摸远程 html 页面。
因此,当用户离开远程页面时关闭浏览器:
cb.onLocationChange = function(loc){
console.log("location = " + loc);
if (loc != "http://example.com") {
cb.close();
}
};
关于redirect - 音隙 : open external page and then go back to app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12940955/