UIWebView 添加 UA 标识。
//get the original user-agent of
webviewUIWebView*webView = [[UIWebViewalloc] initWithFrame:CGRectZero];
NSString*oldAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
NSLog(@"old agent :%@", oldAgent);//add my info to the new agent
NSString*newAgent = [oldAgent stringByAppendingString:@"Bobo_Ma"];
NSLog(@"new agent :%@", newAgent);//regist the new agent
NSDictionary*dictionnary = [[NSDictionaryalloc] initWithObjectsAndKeys:newAgent,@"UserAgent",nil];
[[NSUserDefaultsstandardUserDefaults] registerDefaults:dictionnary];
网友评论