//webview with the H5 Click the Interactive walk Agent
-(BOOL) WebView: (UIWebView *) WebView shouldstartloadwithrequest: (nsurlrequest *) Request Navigationtype: ( Uiwebviewnavigationtype) Navigationtype
{
Nsurl * url = [request URL];
NSString * urlstr = url.absolutestring;
NSString * Protocolprefix = @ "scheme";// and background-defined characters
[Self h5js:protocolprefix url:urlstr];
return YES;
}
// Array Separation Parameters get started with keyword extraction and related actions
-(void) H5js: (NSString *) protocolprefix URL: (NSString *) urlstr
{
if ([[Urlstr Lowercasestring]hasprefix:protocolprefix])
{
URLSTR = [Urlstr stringbyreplacingpercentescapesusingencoding:nsutf8stringencoding];
Nsarray * components = [Urlstr componentsseparatedbystring:@ ":"];// with ":" intercepts characters
Nsarray * Shareurl = [urlstr componentsseparatedbystring:@ "?"];
NSLog (@ "%@", components);
NSString * prefix = components[1];
if ([prefix isequaltostring:@ "Awardlogin"])
{
Isreash = YES;
[Self jumplogin];
}
if ([prefix isequaltostring:@ "Awardbindmobile"])
{
Binding Phone
Modifyphonecontroller * Phone = [[Modifyphonecontroller alloc]init];
[Email protected] " bind phone ";
[Self.navigationcontroller Pushviewcontroller:phone Animated:yes];
}
if ([prefix rangeofstring:@ "awardshare"].location!=nsnotfound)
{
Nsrange Range1 = [Urlstr rangeofstring:@ "?"];/ / match the resulting subscript
NSLog (@ "rang:%@", Nsstringfromrange (range));
NSString *rangestr =[urlstr substringfromindex:range1.location+1];
Nsarray * parameter = [rangestr componentsseparatedbystring:@ "&"];
NSLog (@ "%@", parameter);
[DiC setobject:[parameter[1] componentsseparatedbystring:@ "="][1] forkey:@ "Sharetitle"];
[DiC setobject:[parameter[2] componentsseparatedbystring:@ "="][1] forkey:@ "sharecontent"];
[DiC setobject:[parameter[0] componentsseparatedbystring:@ "="][1] forkey:@ "shareimg"];
[DiC setobject:[parameter[3] componentsseparatedbystring:@ "="][1] forkey:@ "Shareurl"];
Nsrange range = [Parameter[4] rangeofstring:@ "="];// match the resulting subscript
NSLog (@ "rang:%@", Nsstringfromrange (range));
NSString *rangestr1 =[parameter[4] substringfromindex:range.location+1];
[DiC setobject:rangestr1 forkey:@ "Smscontent"];
[Self share:nil];
}
}
}
// Callback JS Code
NSString * Str =[nsstring stringwithformat:@ "Lsf_login_callback (%@)", [User Shareuser].userid];
Refresh The HTML5 page after the comment is finished
[Self.webview STRINGBYEVALUATINGJAVASCRIPTFROMSTRING:STR];
This article is from the "zhuoking" blog, make sure to keep this source http://9951038.blog.51cto.com/9941038/1842724
JS interaction with IOS HTML5