码迷,mamicode.com
首页 > 移动开发 > 详细

iOS webview 交互

时间:2014-11-15 12:54:16      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:io   ar   os   java   for   on   log   cti   ad   

-(void)webViewDidFinishLoad:(UIWebView *)webview
{
    NSString *currentURL = [webView stringByEvaluatingJavaScriptFromString:@"document.location.href"];
    NSString *title = [webview stringByEvaluatingJavaScriptFromString:@"document.title"]; 
    NSString *js_result = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByName('q')[0].value='heyuan110';"];
    
    NSString *js_result2 = [webView stringByEvaluatingJavaScriptFromString:@"document.forms[0].submit(); "];
    
    NSLog(@"%@====%@====%@====%@",currentURL,title,js_result,js_result2);
    
    [webView stringByEvaluatingJavaScriptFromString:@"var script = document.createElement('script');"  
     "script.type = 'text/javascript';"  
     "script.text = \"function myFunction() { "  
     "var field = document.getElementsByName('q')[0];"  
     "field.value='heyuan110.com';"  
     "document.forms[0].submit();"  
     "}\";"  
     "document.getElementsByTagName('head')[0].appendChild(script);"];   
    [webView stringByEvaluatingJavaScriptFromString:@"myFunction();"];  

}

iOS webview 交互

标签:io   ar   os   java   for   on   log   cti   ad   

原文地址:http://blog.csdn.net/zz_mm/article/details/41144545

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!