Cla*_*aus 9 javascript browser window.location ipad cordova
您好我正在尝试使用PhoneGap为iPad开发应用程序.我想在index.html页面内部加载外部网站的主页面.不幸使用
window.location.href = "http://mywebsite.com/cgi-bin/index.py"
Run Code Online (Sandbox Code Playgroud)
触发打开Safari窗口而不是使用PhoneGap容器.
有什么建议?
非常感谢
克劳斯
有一个更简单的选项:修改config.xml
打开WebView中的所有链接
保持在webview中,值为true或false
例:
<preference name="stay-in-webview" value="true" />
如果设置为true,则所有链接(即使目标设置为空白)都将在应用程序的webview中打开
如果您希望服务器中的页面接管整个应用程序,则仅使用此首选项
默认为false
资料来源:https://build.phonegap.com/docs/config-xml
小智 3
在项目的“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 ];
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
11119 次 |
最近记录: |