Added optional support for javascript to the WebView (#134)

This commit is contained in:
nehresma 2017-09-05 14:12:54 -04:00 committed by Sebastián Katzer
parent d2486217f0
commit 8b1f92a0a1

View File

@ -218,11 +218,15 @@ public class Printer extends CordovaPlugin {
Activity ctx = cordova.getActivity(); Activity ctx = cordova.getActivity();
view = new WebView(ctx); view = new WebView(ctx);
WebSettings settings = view.getSettings(); WebSettings settings = view.getSettings();
final boolean jsEnabled = props.optBoolean("javascript", false);
settings.setDatabaseEnabled(true); settings.setDatabaseEnabled(true);
settings.setGeolocationEnabled(true); settings.setGeolocationEnabled(true);
settings.setSaveFormData(true); settings.setSaveFormData(true);
settings.setUseWideViewPort(true); settings.setUseWideViewPort(true);
if (jsEnabled) {
settings.setJavaScriptEnabled(jsEnabled);
}
view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); view.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {