ios - How we change content of WebView -
i want change content of web view when user click bold,italic,underline corresponding change value in html string. implementing code .it change on view how change value in html. newer in ios. please help.any appreciated.
- (bool)canperformaction:(sel)action withsender:(id)sender { nslog(@"canperfom action:called"); nslog(@"canperformaction: called"); nslog(@" action %@", nsstringfromselector(action)); if (action == @selector(_showtextstyleoptions:)) { nslog(@"hello"); return no; } if (action==@selector(toggleboldface:)) { nslog(@"bye"); return no; } return [super canperformaction:action withsender:sender]; } - (void)webviewdidfinishload:(uiwebview *)thewebview { [thewebview stringbyevaluatingjavascriptfromstring:@"document.body.style.webkittouchcallout='none'; document.body.style.khtmluserselect='none'"]; nsstring *js = @"var stylenode = document.createelement('style');\n" "stylenode.type = 'text/css';\n" "var styletext = document.createtextnode('a {-webkit-tap-highlight-color:rgba(0,0,0,0)}');\n" "stylenode.appendchild(styletext);\n" "document.getelementsbytagname('head')[0].appendchild(stylenode);\n"; [thewebview stringbyevaluatingjavascriptfromstring:js]; }
nsstring *tempmailbodystring= [nsstring stringwithformat:@"%@",mytextview.text]; nsstring * htmlstring = [globals replaceregex:@"(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))" : tempmailbodystring : [nsstring stringwithformat:@" $1$2 "]];
i think can is, when button clicked, inject javascript , add style html did in webviewdidfinishload: , have load modified html webview. think using stringbyevaluatingjavascriptfromstring: wrong. returns modified html , have load webview as
returnedhtmlstring = [thewebview stringbyevaluatingjavascriptfromstring:js]; [thewebview loadhtmlstring:returnedhtmlstring baseurl:nil];
Comments
Post a Comment