Logo Icon Logo
A Crowd-sourced Cookbook on Writing Great Android® Apps
GitHub logo Twitter logo OReilly Book Cover Art
Don't Allow JavaScript in WebViewBack to Android Cookbook Home | Up to Chapter: Securing Your Application

Author: Ian Darwin ('idarwin')
In Published Edition? Yes
FormatLanguage: AsciiDoc

Don't Allow JavaScript in WebView

Problem

You don't want vast swathes of undisciplined code running in every WebView

Solution

Don't call setEnableJavaScript(true).

Discussion

Of course this will break JS frameworks.

Download

The source code for this project is in the Android Cookbook repository, http://github.com/IanDarwin/Android-Cookbook-Examples/tree/master/