get content of webview in nativescript

前端 未结 2 368
刺人心
刺人心 2021-01-28 11:00

Is there a way I can read the content of webview after the page is loaded ?

The reason is redirect (like window.location.replace or window.location.href ) is not workin

2条回答
  •  盖世英雄少女心
    2021-01-28 11:36

    I was only looking for IOS. I found the answer and sharing it here. For Android I would like to point some leads.

    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)
    }
    

    Some stack overflow lead for Android

提交回复
热议问题