Javascript 颤振webview_颤振:无法使用java脚本代码检测平台
我正在使用webview_flatter显示网页。我使用下面的代码来检测平台,比如android还是ios。我下面的代码不工作。 颤振网络视图- 我在正文中添加了下面的类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')
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小部件吗。