wkwebview方法如下:

[webView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id result, NSError *error) {
        NSString *string=result;
        NSLog(@"result====%@",string);
    }];

 

uiwebview方法如下:

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
NSString *string = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];