I am trying to call an existent function from a remote site in a WKWebview:
function addtext (text) {
jQuery("#webviewtest").html(text);
}
With:
[self.WebView evaluateJavaScript:@"addtext(\"This is a text from app\");" completionHandler:^(id Result, NSError * error) {
NSLog(@"Error -> %@", error);
}];
But this is throwing an error:
Error Domain=WKErrorDomain Code=4 "A JavaScript exception occurred" UserInfo=0x170c788c0 {NSLocalizedDescription=A JavaScript exception occurred}
This is so simple! I am must missing something really stupid!
document.getElementById('webviewtest').innerHTML = text;
. Maybehtml
method fails. – Particle