Is there a way to catch web console errors?

Using WebView, some websites take a very long time to complete the page loading (as in WebViewClient.onPageFinished () ), and when this happens, it is characterized by the following types of web console errors:

E/Web Console(1916): Unsafe JavaScript attempt to access frame with URL http://mobile.example.com from frame with URL http://ad.doubleclick.net/adi/interactive.example.com/front_sub;sz=320x50;ord=7340930261983. Domains, protocols and ports must match. 05-26 10:44:15.274: E/Web Console(1916): at null:1 

I would like to be able to catch these errors and handle them somehow. for example to give a message or something related to my application, the actual processing at the moment is not related to the main question:

Is there any way to catch these errors? those. How can my application be notified?

Note: This is not a Javascript question. I do not program the site. I am accessing an existing website whose implementation is beyond my control. This is a question

+8
android webview android-webview
source share
2 answers

Do you have an example website?

You can override WebChromeClient.onConsoleMessage(ConsoleMessage consoleMessage).

+5
source share

I suggest this example provided by google for Debugging web applications

Note that only β€œpart1” is displayed when you provide a comma-separated list of parameters in the console.log function, here is a javascript code snippet to verify that:

 console.log("part1","part2"); 

The result will be:

 part1 -- From line 1 of http://example.js10/test.js 
0
source share

All Articles