47355

Alert dialog from was blocked

Dart doesn't show the alert dialog when I use a webview and show this error:

: An alert dialog was blocked. (extensions::webViewEvents:225)

: A confirm dialog was blocked. (extensions::webViewEvents:225)

Does anyone know how to bypass the problem or how to catch the error?

Thanks.

Sorry for my bad English.

<strong>Edit</strong>

The code used:

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

The webview loads a page that works on a js not created by me.

The error occurs when using this:

alert("***")

Answer1:

A webview cannot show those by default.

You need to catch the 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

Answer2:

more Clarification on @Xan Answer:

you need to listen to the dialog event from the webview ,Please read the comments in the code to understand better , again, I am using nwjs, so you can implement similar version in your language:

//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

Recommend

  • How to open doc file in android from url
  • dart error - could not start pub serve or connect to pub
  • How to check and uncheck all items when checking or unckeck some of the items
  • Using Java's built-in Set classes to count EACH(keyword) unique element in List values from a l
  • Integer Linear Programming Java: Multiple Open Source and Commercial tools are available. Which one
  • Realm, query for objects in realm using swift
  • Android Google Maps: Polygon or shape that hides entire map
  • Docker container for google cloudML on compute engine - authenticating for mounting bucket
  • Is the listview recycling early? Or is Universal ImageLoader canceling in error? Or is my Logic wron
  • Eclipse dark color theme fixes
  • PHP Laravel executing many ajax request at same time will give a 'encryption key' server e
  • WPF Animation doesn't run first time
  • Browserify and Reactify source maps include full local path names
  • ONLY Visible Div form elements will get submitted
  • How to know if a JFrame is on screen in a multi screen environment
  • CSS Grid, position absolute an element in a css grid item: IMPOSSIBLE
  • integrate POCO library in android ndk
  • Accessing another variable in the same class with a click event
  • Why can't UI components be accessed from a backgroundworker?
  • how to get data attributes of dynamically generated element
  • How to getText() from the input field of an angularjs Application
  • ListItem.Attributes.Add not working
  • Android application: how to use the camera and grab the image bytes?
  • How to revert to previous XCode version?
  • How to get Eclipse Oxygen to run on Java 9
  • CakePHP 2.0.4 - findBy magic methods with conditions
  • How to change the font size of a single index for UISegmentedControl?
  • Is there a javascript serializer for JSON.Net?
  • Installing Hadoop, Java Exception about illegal characters at index 7?
  • Get object from AWS S3 as a stream
  • Deserializing XML into class C#
  • Where to put my custom functions in Wordpress?
  • Convert array of 8 bytes to signed long in C++
  • How to include full .NET prerequisite for Wix Burn installer
  • Buffer size for converting unsigned long to string
  • -fvisibility=hidden not passed by compiler for Debug builds
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize