gpt4 book ai didi

javascript - 来自 的警报对话框被阻止

转载 作者:行者123 更新时间:2023-12-03 13:20:33 26 4
gpt4 key购买 nike

当我使用 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("***")

最佳答案

关于@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

关于javascript - 来自 <webview> 的警报对话框被阻止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30549198/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com