当我使用 webview 并显示此错误时,Dart 不显示警报对话框:
:警报对话框被阻止。 (扩展名::webViewEvents:225)
:确认对话框被阻止。 (扩展名::webViewEvents:225)
有谁知道如何绕过该问题或如何捕获错误?
Thanks.
对不起,我的英语不好。
Edit
使用的代码:
Element webview= querySelector("#webview");
Map<String,String> map=new Map();
map["src"]=urlWebView;
webview.attributes.addAll(map);
webview.style.visibility="visible";
DartEditor 版本=稳定版本 45396
SDK版本号=1.10.0
webview 加载一个在不是我创建的 js 上运行的页面。
使用这个的时候会出现错误:
alert("***")
对@Xan 答案的更多澄清:
你需要从webview监听对话框事件,请阅读代码中的注释以更好地理解,同样,我使用nwjs,所以你可以用你的语言实现类似的版本:
//lets listen to alert dom and enable it
webview.addEventListener('dialog',function(e){
//message type
messageType = e.messageType;
messageText = e.messageText;
DialogController = e.dialog;
//lets checki if alert
if(messageType == 'alert'){
window.alert(messageText);
}//emd if
//if confirm
else if(messageType == 'confirm'){
//confirm
var confirm = window.confirm(messageText);
//get confirm bool and send to controller
if(confirm == true){
//if true send okay to browser
DialogController.ok();
}else{
//send cancel with to send false false
DialogController.cancel();
}//end if
}//end if confirm
//lastly if its prompt
else if(messageType == 'prompt'){
//get user Input
promptInput = window.prompt(messageText);
//if null , then means the user clicked cancel
if(promptInput == null){
//tell browser to cancel
DialogController.cancel();
}else{
//feed browser with input data
DialogController.ok(promptInput);
}
}//end if prompt
});//end dialog test
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)