this article reprinted to: Http://blog.chinaunix.net/uid-29415710-id-4058564.html
-(BOOL) WebView: (UIWebView *) WebView shouldstartloadwithrequest: (nsurlrequest *) Request Navigationtype: ( Uiwebviewnavigationtype) Navigationtype {
Nsurl * url = [request URL];
if ([[[URL scheme] isequaltostring:@ "AAA"]) {
Nsarray * Separatedarray = [[Nsarray alloc]init];
Nsmutablearray *temp = [[Nsmutablearray alloc] init];
Separatedarray = [[[url absolutestring] stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding] Componentsseparatedbystring:@ ","];
[Temp Addobjectsfromarray:separatedarray];
NSLog (@ "code1__%@:", [[url absolutestring] stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding]);
NSLog (@ "Url__scheme%@", [url absolutestring]);
Self.taskdownloader = [[Multitaskdownloader alloc] init];
Taskdownloader.delegate = self;
for (int i = 0; i < separatedarray.count-1; i++) {
Nsarray *filenames = [[Separatedarray objectatindex:i] componentsseparatedbystring:@ "^"];
NSString * FileName = [FileNames lastobject];
NSLog (@ "ABC---%@", fileName);
[Temp replaceobjectatindex:i withobject:filename];
[Taskdownloader Addtaskurl:[[[separatedarray objectatindex:separatedarray.count-1] stringByAppendingString: @ "/ Files/"] stringbyappendingstring:[filename stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]];
[Taskdownloader Addtaskfielname:filename];
NSLog (@ "Filename--00-%ld", (long) separatedarray.count);
}
[Taskdownloader start];
return NO;
}
Above is the main code in iOS. is to intercept the URL. According to what is intercepted. Perform the corresponding judgment.
function Loadurl (URL) {
var iFrame;
iframe = document.createelement ("iframe");
Iframe.setattribute ("src", url);
Iframe.setattribute ("Style", "display:none;");
Iframe.setattribute ("height", "0px");
Iframe.setattribute ("width", "0px");
Iframe.setattribute ("frameborder", "0");
Document.body.appendChild (IFrame);
This iframe is useless after initiating a request, so remove it from the DOM.
IFrame.parentNode.removeChild (IFrame);
IFrame = null;
}
After that, it's how to send the URL. Very simple. Look at the code above yourself. It's like this when you want to use it:
Loadurl ("AAAA:"));
This way, you can intercept the AAAA on iOS.
And then. It's what you want to do after you intercept.
The code is simple. Let's see. In addition, for iOS development, it is recommended that novice look at the iOS API more. A simple function, people who are not familiar with the API will have to pay a great deal of effort to achieve, and in fact, with the API a word can be solved. This is not familiar to the API is easy to detour.
For more information on iOS development , check out Heaven http://ios.9tech.cn/