jQuery get the location of an element relative to window

Initially, Grab the .offset position of the element and calculate its relative position with respect to window Refer : 1. offset 2. scroll 3. scrollTop You can give it a try at this fiddle Following few lines of code explains how this can be solved when .scroll event is performed, we calculate the relative position … Read more

android.view.InflateException Error inflating class android.webkit.WebView

If you use androidx.appcompat:appcompat:1.1.0, try androidx.appcompat:appcompat:1.0.2 instead. it seems that 1.1.0 doesn’t fix the bug with WebView in Android 5.1.1. Feb-2020 update: Reverting to 1.0.2 stopped working for many people (including my app), but using the current version of androidx.appcompat:appcompat:1.2.0-alpha02 did fix the crash. (I was seeing it on a Huawei P8 Lite running Android … Read more

Android WebView: handling orientation changes

If you do not want the WebView to reload on orientation changes simply override onConfigurationChanged in your Activity class: @Override public void onConfigurationChanged(Configuration newConfig){ super.onConfigurationChanged(newConfig); } And set the android:configChanges attribute in the manifest: <activity android:name=”…” android:label=”@string/appName” android:configChanges=”orientation|screenSize” for more info see: http://developer.android.com/guide/topics/resources/runtime-changes.html#HandlingTheChange https://developer.android.com/reference/android/app/Activity.html#ConfigurationChanges

Is `shouldOverrideUrlLoading` really deprecated? What can I use instead?

Documenting in detail for future readers: The short answer is you need to override both the methods. The shouldOverrideUrlLoading(WebView view, String url) method is deprecated in API 24 and the shouldOverrideUrlLoading(WebView view, WebResourceRequest request) method is added in API 24. If you are targeting older versions of android, you need the former method, and if … Read more

How to pass html string to webview on android?

i have successfully done by below line //data == html data which you want to load String data = “Your data which you want to load”; WebView webview = (WebView)this.findViewById(R.id.webview); webview.getSettings().setJavaScriptEnabled(true); webview.loadData(data, “text/html; charset=utf-8”, “UTF-8”); Or You can try webview.loadDataWithBaseURL(null, data, “text/html”, “utf-8”, null);

Swift Open Link in Safari

It’s not “baked in to Swift”, but you can use standard UIKit methods to do it. Take a look at UIApplication’s openUrl(_:) (deprecated) and open(_:options:completionHandler:). Swift 4 + Swift 5 (iOS 10 and above) guard let url = URL(string: “https://stackoverflow.com”) else { return } UIApplication.shared.open(url) Swift 3 (iOS 9 and below) guard let url = … Read more

Android webview slow

It depends on the web application being loaded. Try some of the approaches below: Set higher render priority (deprecated from API 18+): webview.getSettings().setRenderPriority(RenderPriority.HIGH); Enable/disable hardware acceleration: if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // chromium, enable hardware acceleration webView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } else { // older android version, disable hardware acceleration webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } Disable the cache (if … Read more

File Upload in WebView

This is a full solution for all android versions, I had a hard time with this too. public class MyWb extends Activity { /** Called when the activity is first created. */ WebView web; ProgressBar progressBar; private ValueCallback<Uri> mUploadMessage; private final static int FILECHOOSER_RESULTCODE=1; @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { if(requestCode==FILECHOOSER_RESULTCODE) … Read more