Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 颤振webview_颤振:无法使用java脚本代码检测平台_Javascript_Html_Css_Flutter - Fatal编程技术网

Javascript 颤振webview_颤振:无法使用java脚本代码检测平台

Javascript 颤振webview_颤振:无法使用java脚本代码检测平台,javascript,html,css,flutter,Javascript,Html,Css,Flutter,我正在使用webview_flatter显示网页。我使用下面的代码来检测平台,比如android还是ios。我下面的代码不工作。 颤振网络视图- 我在正文中添加了下面的类 class - view-withKeyboard function applyAfterResize() { console.log(getMobileOperatingSystem()); if (getMobileOperatingSystem() == 'ios')

我正在使用webview_flatter显示网页。我使用下面的代码来检测平台,比如android还是ios。我下面的代码不工作。 颤振网络视图- 我在正文中添加了下面的类

class - view-withKeyboard


function applyAfterResize() {
            console.log(getMobileOperatingSystem());
            if (getMobileOperatingSystem() == 'ios') {
                if (originalPotion !== false) {
                    var wasWithKeyboard = $('body').hasClass('view-withKeyboard');
                    var nowWithKeyboard = false;
                        var diff = Math.abs(originalPotion - ($(window).width() + $(window).height()));
                        if (diff > 100) nowWithKeyboard = true;
                    $('body').toggleClass('view-withKeyboard', nowWithKeyboard);
                    if (wasWithKeyboard != nowWithKeyboard) {
                        //onKeyboardOnOff(nowWithKeyboard);
                    }
                }
            }
        }
        $(document).on('focus blur', '.white-div input[type=text]', function(e){
            //alert('here');
            if (getMobileOperatingSystem() == 'ios') {
              var $obj = $(this);
              var nowWithKeyboard = (e.type == 'focusin');
              $('body').toggleClass('view-withKeyboard', nowWithKeyboard);
              onKeyboardOnOff(nowWithKeyboard);
            }
        });

首先启用JavascriptMOde并使用evaluateJavascript

WebView(
    javascriptMode: JavascriptMode.unrestricted,
    initialUrl: '',
    onWebViewCreated:
        (WebViewController webViewController) async {
      webViewController.evaluateJavascript(
          "javascript:(function() { " +
              "console.log('Test Test Test');" +
              "})()");
    },
  ),

你能给我们展示一下如何使用WebView小部件吗。