Blog · 23/09/2021
WebView does not display Slider Revolution
In the development of a Hybrid App, using the WebView to show the web pages of a WordPress appeared a pretty strange problem a priori.
WordPress was using the Plugin Slider Revoluti on to show a fantastic Slider at the beginning of the page.
The situation is that in the browser, both on the computer and on the mobile the slider perfectly loads and is seen.
But in the WebView of the application, directly did not appear the Slider in addition, it was having errors representation with the Favicons .
The application is being programmed on Klotin using Android Studio .
The code here exposed is for Klotin , but you can use the same solution if you use Java, through the syntax of Java .


WebView in Edge or Chorme
The first thing that was done was to look for the problem using the cleaning console that has the Edge browser (also Chrome).
edge://inspect/#devices

In this way you can access the depurator and see the page loaded in the WebView of the application, important, so that the browser can depur the WebView it is necessary to add the following instructions to allow the depuration.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true)
}
Pulsing on inspect on the loaded page is possible to see the cleanser and try to investigate a little for the problem.

Fixing JavaScript errors
After examining the console and all the code it came to the conclusion that JavaScript was not loading correctly, and this makes sense, since the WebView by default does not load JavaScript.
So by activating the JavaScript load on the WebView it seemed that the problem was going to be solved:
binding.webViewPrincipal.settings.javaScriptEnabled = true
After adding to activate JavaScript, a improvement was obtained, at least it carried the Slider container, that is, where it should appear, although it still did not correctly show the images.


Now the depurator shows a series of JavaScript errors, for the error messages everything indicated a DOM error.
Also with some features of HTML5, so everything leads us to the conclusion.
It was necessary to activate some additional feature in the WebView.
Solution of DOM errors
After investigating, we determined that there was a default-deactivated feature in WebView responsible for the DOM storage, which is default-deactivated.
Therefore, it was necessary to add the following instructions in the code:
binding.webViewPrincipal.settings.domStorageEnabled = true
When we tried, we finally had the Slider working properly on the WebView, while there will be a lot of problems that come from having these options disabled.

If you want more information you can visit the following article: https://www.flipandroid.com/qu-significa-enable-dom-storage-api.html