Because WebView load is the Web page can only be used to search the page with JS nonsense do not say on the code
//Inject JS SearchNSString *respath =[[NSBundle Mainbundle] resourcepath]; StaticNSString *jsquery =Nil; Staticdispatch_once_t Oncetoken; Dispatch_once (&oncetoken, ^{jsquery= [NSString Stringwithcontentsoffile:[respath stringbyappendingpathcomponent:@"Js_plugins.js"] encoding:nsutf8stringencoding Error:nil]; }); NSString*js = [NSString stringWithFormat:@"var highlightplugin = document.getElementById (' js_plugins '); if (Highlightplugin = = undefined) {Document.body.innerHTML + = ' <div id=\"Js_plugins\"> \<style type=\"text/css\ "> \. utahighlight {background-Color:yellow;} . selectspan {Background-color:yellow; color:red;} </style> </div>'; \%@ }", Jsquery];[self stringbyevaluatingjavascriptfromstring:js]; //clears the last highlight and sets the current keyword highlighting[Self stringbyevaluatingjavascriptfromstring:[nsstring stringWithFormat:@"jQuery (' body '). Removehighlight (). Utahighlight ('%@ ');", str]]; //get the number of keywordsNSString *count = [Self stringbyevaluatingjavascriptfromstring:@"jQuery ('. Utahighlight '). Length"]; if([Count Integervalue]>0) {[Self Focustofindindex:0]; }
dispatch_once Use a single case without having to read the file once per call, followed by some methods of invoking some JS files.
Extensible previous next, not implemented for the time being.
Other specific file methods can be seen in demo
Http://pan.baidu.com/s/1eQAGNPC
Ios:webview Inside Highlight Search