merlin2049er Well-Known Member Licensed User Longtime User Apr 2, 2015 #1 I wrapped a mobile site within a webview. It seems to work well, but there is one thing that fails to load. I think it's a java script popup, how would that be handled within the webview? Thanks, Joe
I wrapped a mobile site within a webview. It seems to work well, but there is one thing that fails to load. I think it's a java script popup, how would that be handled within the webview? Thanks, Joe
merlin2049er Well-Known Member Licensed User Longtime User Apr 2, 2015 #2 Ok, I think I need to use the webview extra library and intercept that url? Upvote 0
warwound Expert Licensed User Longtime User Apr 2, 2015 #3 WebViewExtras addWebChromeClient method will enable javascript modal dialogs such as alert and prompt. https://www.b4x.com/android/forum/threads/webviewextras.12453/ Upvote 0
WebViewExtras addWebChromeClient method will enable javascript modal dialogs such as alert and prompt. https://www.b4x.com/android/forum/threads/webviewextras.12453/
merlin2049er Well-Known Member Licensed User Longtime User Apr 4, 2015 #4 Ok, thanks. But can I actually trap the java script that's already on the mobile site and replace it with my own msgbox ? Upvote 0
Ok, thanks. But can I actually trap the java script that's already on the mobile site and replace it with my own msgbox ?
warwound Expert Licensed User Longtime User Apr 4, 2015 #5 Look at the documentation for the WebChromeClient: http://developer.android.com/reference/android/webkit/WebChromeClient.html Look at the callbacks such as onJsAlert and onJsPrompt. If you use WebViewExtras to add a WebChromeClient to a WebView then you'll get the default implementation of these callbacks. The dialogs will be the default dialogs as styled by the creators of android. In theory (and in java) you could override any of these WebChromeClient callbacks and display your own dialog instead of the default dialog. You could probably do this using inline java in b4a - though i've no real idea how complicated or time consuming it'd be. Martin. Upvote 0
Look at the documentation for the WebChromeClient: http://developer.android.com/reference/android/webkit/WebChromeClient.html Look at the callbacks such as onJsAlert and onJsPrompt. If you use WebViewExtras to add a WebChromeClient to a WebView then you'll get the default implementation of these callbacks. The dialogs will be the default dialogs as styled by the creators of android. In theory (and in java) you could override any of these WebChromeClient callbacks and display your own dialog instead of the default dialog. You could probably do this using inline java in b4a - though i've no real idea how complicated or time consuming it'd be. Martin.