iOS + UIWebView 实践

1. 调用java script 

现在只能实现弹出窗口

[self.m_webView stringByEvaluatingJavaScriptFromString:@"alert(1)"];

 2. 获取页面的标签

NSString *title = [self.m_webView stringByEvaluatingJavaScriptFromString:@"document.title"];

 3. 页面调用函数

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    
    if ([request.URL.absoluteString rangeOfString:@"shareMessIOS"].location!=NSNotFound)
    {
        NSString *utf8 = [request.URL.absoluteString stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        NSArray *array = [utf8 componentsSeparatedByString:@"<|#@VGSEPERATOR@#|>"];
    
        NSString * ss = [array objectAtIndex:1];
        NSLog(@"intro=%@",array );


        
        return NO;
    }
    
    return YES;
}

 应该会进来两次,或者以上。第一次不会进入到if ,第二次才进来。

posted on 2016-03-17 16:11  大木哥  阅读(319)  评论(0编辑  收藏  举报

导航