0

あるサイトから html コードを取得し、フラッター webview で使用しようとしましたが、何も起こりませんでした。クロムから通常どおりファイルを開くと、すべてがうまく見えます。これは私のhtmlコードです:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script src="https://export.otpusk.com/api/session?access_token=***"></script>
<script src="https://export.otpusk.com/js/onsite/"></script>
<script src="https://export.otpusk.com/js/order"></script>
</body>
</html>

そして、私はそれをどのように使用しますか:

  String filePath = "assets/index.html";
  WebViewController webViewController;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("App bar"),),
      body: WebView(
        initialUrl: 'about:blank',
        javascriptMode: JavascriptMode.unrestricted,
        onWebViewCreated: (WebViewController webview){
          webViewController = webview;
          _loadHtmlFromAssets();
        },
      ),
    );
  }
  _loadHtmlFromAssets() async{
    String fileHtmlContents = await rootBundle.loadString(filePath);
    webViewController.loadUrl(Uri.dataFromString(fileHtmlContents,mimeType: 'text/html',encoding: Encoding.getByName('utf-8')).toString());
  }

コンソールでは、次のようなものが得られます。

I/chromium(13344): [INFO:CONSOLE(1)] "A parser-blocking, cross site (i.e. different eTLD+1) script, https://export.otpusk.com/jsapi/onsite.min.js?_time=20200525, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message. See https://www.chromestatus.com/feature/5718547946799104 for more details.", source: https://export.otpusk.com/js/onsite/ (1)
I/chromium(13344): [INFO:CONSOLE(1)] "A parser-blocking, cross site (i.e. different eTLD+1) script, https://export.otpusk.com/jsapi/onsite.min.js?_time=20200525, is invoked via document.write. The network request for this script MAY be blocked by the browser in this or a future page load due to poor network connectivity. If blocked in this page load, it will be confirmed in a subsequent console message. See https://www.chromestatus.com/feature/5718547946799104 for more details.", source: https://export.otpusk.com/js/onsite/ (1)
I/chromium(13344): [INFO:CONSOLE(24)] "Uncaught SecurityError: Failed to read the 'cookie' property from 'Document': Cookies are disabled inside 'data:' URLs.", source: https://export.otpusk.com/jsapi/onsite.min.js?_time=20200525 (24)

どうすればこれを修正できますか、またはウェブサイトのすべてではなく一部だけを読み込むにはどうすればよいですか?

4

0 に答える 0