In the end all the suggested solutions didn't work for me. So I implemented a native image gallery for the image. I used this tutorial Fullscreen Image Slider as a reference for building my own one. Works out pretty sweet.
Find out error of Android WebView loading an URL with Javascript
-
15-07-2023 - |
문제
I use a Android WebView to display a URL, which holds a image gallery, with a kind of lightbox feature to show images in detail using Javascript.
When I call this URL in the Browser App. It loads fine, and works as expected. But when I load the same URL in a WebView of a Android App, the image overview gets loaded, but when I tap on a image to get the lightbox up, it does not show.
WebView webView = (WebView) rootView.findViewById(R.id.fragment_image_detail_webview);
String imageDetailUrl = getResources().getString(R.string.json_page_url) + imageGallery.get("detailLink");
webView.loadUrl(imageDetailUrl);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new InsideWebViewClient());
So JavaScript should be enabled. The Apps internal browsers seems to behave differntly than the App Browser!?
Any ideas, on how I could narrow down the errror?
Thanks
해결책 3
다른 팁
wv = (WebView)findViewById(R.id.webView1);
WebSettings webSettings = wv.getSettings();
wv.getSettings().setJavaScriptEnabled(true);
wv.getSettings().setBuiltInZoomControls(true);
wv.loadUrl("http://www.accelfrontline.com");
Try this code hope this will be useful..
Try adding these lines to onCreate()
super.init();
WebView webView=new WebView(this);
webView.getSettings().setJavaScriptEnabled(true);
//Add these lines according to your requirements
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setSaveFormData(true);
webView.getSettings().setAllowContentAccess(true);
webView.getSettings().setAllowFileAccess(true);
webView.getSettings().setAllowFileAccessFromFileURLs(true);
webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
//webView.getSettings().setSupportMultipleWindows(true);
webView.getSettings().setSupportZoom(true);
webView.setWebViewClient(new WebViewClient());
webView.setClickable(true);
webView.setWebChromeClient(new WebChromeClient());
webView.loadUrl("Your webpage link");
setContentView(webView);
제휴하지 않습니다 StackOverflow