I need some sample code to check if the page is ‘file’, ‘http’ or ‘www’ on the page load. At the moment the code is as follows;
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
//CAPTURE USER LINK-CLICK.
if (navigationType == UIWebViewNavigationTypeLinkClicked) {
NSURL *URL = [request URL];
if ([[URL scheme] isEqualToString:@"file"]) {
[webView loadRequest:request];
[homebutton setHidden:YES];
NSLog(@"Opened File");
return NO;
}
else if ([[URL scheme] isEqualToString:@"http"]) {
[webView loadRequest:request];
[homebutton setHidden:NO];
NSLog(@"Opened External Page");
return NO;
}
else if ([[URL scheme] isEqualToString:@"www"]) {
[webView loadRequest:request];
[homebutton setHidden:NO];
NSLog(@"Opened External Page");
return NO;
}
}
return YES;
}
I want it based around this but this is only when a link is clicked and I want it to apply when a form is filled out and then the form redirects to another page etc…
I would really appreciate a quick answer,
Thank you very much,
James Anderson
Probably you need to check out the various
UIWebViewNavigationTypelisted in the “constants” section here