0

I need to pass certain values to my HTML from WKWebview.

Here is my code snipped of what I've tried yet.

 [self.webView evaluateJavaScript:@"document.getElementById('popo_data').innerHTML = feed,OMG,BTC;" completionHandler:^(NSString *result, NSError *error) {
         if(error != nil) {
             NSLog(@"######## SomeFunction Error: %@",error);
             return;
         }

         NSLog(@"########  SomeFunction Success");
     }];

1 Answer 1

1

That does not look like well formed JavaScript, because quotes are missing around the string you're assigning to the #popo_data element. I suppose you're getting a syntax error here.

Try the following: document.getElementById('popo_data').innerHTML = "feed,OMG,BTC"

If this does not work, you can debug your webview with Safari by connecting the debugger to your device or simulator. Safari Preferences > check "Show Develop menu in menu bar."

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

2 Comments

WKJavaScriptExceptionMessage=TypeError: null is not an object (evaluating 'document.getElementById('popo_data').innerHTML = 'feed,OMG,BTC' '), Getting this error when trying your code.
Then this is likely that at time of evaluation, there is not HTML element with id="popo_data" present in the web document.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.