SyntaxHighlighter

Saturday, March 11, 2017

NativeScript WebView - Getting the HTML Content

If you're trying to get the content from a NativeScript WebView, try the following from StackOverflow

if (webView.ios) {
    var webHeader = webView.ios.stringByEvaluatingJavaScriptFromString("document.head.innerHTML").trim();
    console.log(webHeader);

    var webBody = webView.ios.stringByEvaluatingJavaScriptFromString("document.body.innerHTML").trim();
    console.log(webBody);

} else if (webView.android) {
    webTitle = webView.android.getTitle(); //getting the title title
    console.log(webTitle)
}

No comments:

Post a Comment