来自 <webview> 的警报对话框被阻止

Mal*_*Dev 2 javascript webview dart google-chrome-app

当我使用 webview 并显示此错误时,Dart 不显示警报对话框:

:警报对话框被阻止。(扩展名::webViewEvents:225)

:确认对话框被阻止。(扩展名::webViewEvents:225)

有谁知道如何绕过问题或如何捕捉错误?

谢谢。

对不起,我的英语不好。

编辑

使用的代码:

Element webview= querySelector("#webview");
Map<String,String> map=new Map();
map["src"]=urlWebView;
webview.attributes.addAll(map);
webview.style.visibility="visible";
Run Code Online (Sandbox Code Playgroud)

DartEditor 版本 = 稳定版 45396

SDK版本号= 1.10.0

webview 加载了一个页面,该页面适用于非我创建的 js。

使用时出现错误:

alert("***")
Run Code Online (Sandbox Code Playgroud)

raz*_*bee 5

关于@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 
Run Code Online (Sandbox Code Playgroud)