在 PhoneGap 中调用 window.location.href 会触发 Web 浏览器
你好 我正在尝试使用 PhoneGap 开发 iPad 应用程序。我想在 index.html 页面内动态加载外部网站的主页。 不幸的是,使用
window.location.href = "http://mywebsite.com/cgi-bin/index.py"
触发了 Safari 窗口的打开,而不是使用 PhoneGap 容器。
有什么建议吗?
非常感
谢克劳斯
Hello
I'm trying to develop an application for iPad using PhoneGap. I would like to dinamically load inside the index.html page the main page of an external website.
Unfortunately using
window.location.href = "http://mywebsite.com/cgi-bin/index.py"
triggers the opening of a Safari window instead of using the PhoneGap container.
Any suggestions?
Thanks a lot
Claus
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(2)
南七夏2024-11-12 13:18:34
在项目的“Classes”部分找到AppDelegate.m文件,并找到webView:shouldStartLoadWithRequest:navigationType
让函数看起来像这样,然后再试一次!
- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];
if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) {
[[UIApplication sharedApplication] openURL:url];
return NO;
}
else {
return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
}
}
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
有一个更简单的选项:修改 config.xml
来源:https://build.phonegap.com/docs/config-xml
There's a simpler option: modify config.xml
Source: https://build.phonegap.com/docs/config-xml