停止iframe重定向/在phonegap项目中打开移动safari [英] Stop iframe redirect/opening mobile safari in phonegap project
问题描述
目前,我已经在我的phonegap项目中将一个页面加载到隐藏的iframe中,作为在我的应用程序中使用的移动版网站上的数据。
Currently I have been loading a page into a hidden iframe within my phonegap project as a way of scraping data off a mobile version of a website I use within my app.
问题是一个特定网站有某种类型的框架破坏,并发送一个重定向,退出应用程序并加载移动safari中的页面。
The problem is that one particular site has some type of frame buster and sends a redirect which exits the app and loads the page in mobile safari.
有没有办法停止重新加载?
留下刮除道德: - )
Is there a way to stop the reload ? Leaving the ethics of scraping aside :-)
推荐答案
我在这篇文章中找到了答案
< a href =http://craigpfau.com/2012/02/phonegap-ios-uiwebview-and-safari-app-links/ =nofollow> http://craigpfau.com/2012/02/phonegap -ios-uiwebview-and-safari-app-links /
I found an answer in this post http://craigpfau.com/2012/02/phonegap-ios-uiwebview-and-safari-app-links/
在AppDelegate.m
Replace this in the AppDelegate.m
- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest: (NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
{
NSURL *url = [request URL];
if ([[url absoluteString] rangeOfString:@"URLToOpenInUIWebView.com"].location != NSNotFound) {
return YES;
}
else {
return [self.viewController webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
}
}
您不想在UIwebview中打开的任何链接您使用target =_ blank
Any links you don't want to open in UIwebview you use target="_blank"
这篇关于停止iframe重定向/在phonegap项目中打开移动safari的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!