来自 <webview> 的警报对话框已被阻止
Alert dialog from <webview> was blocked
当我使用 webview 并显示此错误时,Dart 不显示警告对话框:
: An alert dialog was blocked. (extensions::webViewEvents:225)
: A confirm dialog was blocked. (extensions::webViewEvents:225)
有谁知道如何绕过问题或如何捕获错误?
谢谢。
抱歉我的英语不好。
编辑
使用的代码:
Element webview= querySelector("#webview");
Map<String,String> map=new Map();
map["src"]=urlWebView;
webview.attributes.addAll(map);
webview.style.visibility="visible";
DartEditor version= STABLE build 45396
The version number of the SDK= 1.10.0
webview 加载了一个页面,该页面适用于不是我创建的 js。
使用这个时出现错误:
alert("***")
网络视图默认无法显示这些内容。
你需要赶上 dialog
event, show your own UI for it (remember, Apps can't use alert
and friends, so a <dialog>
is a good option) and then pass the response back with DialogController
关于@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
当我使用 webview 并显示此错误时,Dart 不显示警告对话框:
: An alert dialog was blocked. (extensions::webViewEvents:225)
: A confirm dialog was blocked. (extensions::webViewEvents:225)
有谁知道如何绕过问题或如何捕获错误?
谢谢。
抱歉我的英语不好。
编辑
使用的代码:
Element webview= querySelector("#webview");
Map<String,String> map=new Map();
map["src"]=urlWebView;
webview.attributes.addAll(map);
webview.style.visibility="visible";
DartEditor version= STABLE build 45396
The version number of the SDK= 1.10.0
webview 加载了一个页面,该页面适用于不是我创建的 js。
使用这个时出现错误:
alert("***")
网络视图默认无法显示这些内容。
你需要赶上 dialog
event, show your own UI for it (remember, Apps can't use alert
and friends, so a <dialog>
is a good option) and then pass the response back with DialogController
关于@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