1

I have a html content of url:

let task = NSURLSession.sharedSession().dataTaskWithURL(url!) {
        (data, response, error) in 

(url!) is url which is loading and:

let urlContent = String(data: data!, encoding: NSUTF8StringEncoding)

So, urlContent is html content of url which is loading.I have a string

let string = "Custom string in html content"

which i want to add in urlContent, between <body> </body> tags

How can i do this? Thanks

3
  • let me see if I understand, you want to be able to change the HTML code right? Commented Dec 2, 2015 at 9:28
  • yes,then this string will be a javascript code.Is it possible? Commented Dec 2, 2015 at 9:32
  • yes it is. you can append js to one webview. 5 min I will post an answer Commented Dec 2, 2015 at 9:35

1 Answer 1

1
-(void)webViewDidFinishLoad:(UIWebView *)webView {


    [_WebViewPrograma stringByEvaluatingJavaScriptFromString:**(your js here)**];

    [_WebViewPrograma stringByEvaluatingJavaScriptFromString:@"myFunction();"];
}

Use this code, if there is anything that you might need, I will try to help

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.