【发布时间】:2018-04-24 08:56:38
【问题描述】:
我正在为我的服务器页面使用Classic ASP。在webView 上加载以下 URL 时。当用户使用- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType 点击webView 时,我将检测到链接
如果在the webView 上点击新的 URL 链接时检测到classbook.asp,我将触发一个 segue 来加载新的VC 并加载新的webView
但是,webView 触发器上还有另一个谷歌地图链接,由以下 Classic ASP onclick 代码触发。
我如何检测何时在webView 上点击了这个谷歌地图链接?目前上述检测URL链接的方法无法检测到onclick
服务器经典 ASP
<div id="map" onclick="window.open('http://maps.google.com/maps?q=<%=sLat%>,<%=sLongi%>(<%=sFCName%>)', '_system');"></div>
目标 C
@interface ClassesDet (){
AppDelegate *appDelegate;
NSString *sURL;
NSString *sURLFav;
}
@end
@implementation ClassesDet
@synthesize webView;
- (void)viewDidLoad {
[super viewDidLoad];
sURL = @"https://www.share-fitness.com/apps/class_det.asp?classcode=CLS100032&access=C&memcode=SF100035&catcode=YG&fccode=KL00059&dtpclass=24/04/2018&tpfrom=20:15&fav=false&lang=EN&encode=20a728210f0869f04aab6cf1682881816a36f0bd47cc894ac4d8dd22dd0ded24"
NSURL *url = [NSURL URLWithString:sURL];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[webView setDelegate:(id<UIWebViewDelegate>)self];
[webView loadRequest:urlRequest];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
ClassBook *target = segue.destinationViewController;
if ([segue.identifier isEqualToString:@"ClassBook"]) {
NSLog(@" To ClassBook sURL : %@", sURL);
target.urlString = sURL;
} else {
NSLog(@" Else to Other VC and the sURL : %@", sURL);
target.urlString = sURL;
}
}
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NSURL *URL = [request URL];
NSString *theString = [URL absoluteString];
NSRange match;
NSLog(@"The URL Clicked : %@", sURL);
match = [theString rangeOfString: @"classbook.asp"];
//---If the URL string does not contain classbook.asp meaning it is loading the webview.
if (match.location == NSNotFound) {
NSLog(@"Load the webView with this sURL : %@", sURL);
return YES; //---Load webview, the URL will be sURL nothing to do with theString
} else {
sURL = theString;
NSLog(@"Trigger the Segue ClassBook and pass the sURL : %@ Over ",sURL );
//---Calling the following method will trigger the segue and redirect to another viewController.
[self performSegueWithIdentifier:@"ClassBook" sender:self];
return NO; //---Don't load the webview
}
}
@end
【问题讨论】:
标签: ios objective-c webview asp-classic onclick