Open Link In Default Browser from WebView only with Javascript - javascript

Scenario:
Browser opens on WebView
User clicks a link and opens the link on the default browser (Android, Chrome, etc)
I read that opening the default browser by WebView requires implementation on the native App.
But how does that work?
The back-end developer will give me the function and I'll call the function from the front end?
Also, how do I call that function?
Thanks for the help?

Related

Force to open my progressive web app in Chrome from WebView

I developed a Progressive Web App (JS+HTML+CSS), which asks you to "Add to Homescreen" and "Permission for Push Notification" when the user opens it. The problem is that when the URL is opened from a WebView, for example Facebook WebView, the service worker not works.
So I want a way to force the user to open the URL in Chrome mobile. I try using googlechrome://myurl.com or googlechromes://myurl.com but not works, and I also try to create a link like window.open('https://myurl.com, '_system') but not works.
Any ideas? Thanks!

Deep link to another app then callback to the same browser

I have established deep link connection to the android app from mobile web browser now I want to redirect back specific URL to the same browser that the deep link came from. Currently the callback redirects always to the default browser.
Let's say I can identify the browser using the
navigator.userAgentand pass it as parameter in deep ling to the app. What should be included in URI prefix for the Chrome, Firefox, Safari? To always open callback link in the same browser instead of device default one?
Also is it possible to open the same session instead of always the new tab?

Android: Browser close "window"

I wrote a simple WebUI for Android/iPhone where users have an account with logout function. They usually start the application via a bookmark on their homescreen.
I want to give them a handy button to close the web browser/page once the logged out.
Whit the following script, the browser prevents the action
<script>
window.close();
</script>
Is there a workaround that specially works on Android (default browser)?
Used tools/techniques
Tomcat and JSP
jQuery Mobile (1.4.x)
Android 4.2.x with default browser
Bookmark on homescreen
If I understand your question correctly, you want to use script to close the browser window itself? If so, you should read about this:
http://www.javascript-coder.com/window-popup/javascript-window-close.phtml
You'll meet some security restrictions with the close() function call.

Open non-whitelisted URLs in Cordova in ChildBrowser rather than main Webview

I'm trying to implement the official Twitter and Facebook share buttons in my Cordova/Phonegap app, and I'm running into major difficulties with them. Both of them attempt to load an iframe element to display their buttons, which works, but clicking either of them causes them to open in the Webview, with no way to open them instead in the ChildBrowser. This becomes an issue when the user is done sharing but can't go back to the app due to a lack of navigation buttons.
Is there some way to open a list of URLs in ChildBrowser by default instead of Webview?
Well you can use the:
ChildBrowser.showWebPage();
command to open non-white listed URL's.
Coming in 2.3.0 we will overload window.open() in so that you can specify whether or not you want the url opened in the main web view, the OS browser or the special in app browser that does not have access to the Cordova API.

Closing a mobile browser tab with javascript

I need a native app to fire a browser with some URL that will take the user to a mobile website. Inside the mobile website, there has to be a button that closes the browser (or sends any signal to the native app) so that the user gets back to the native app. Currently I'm trying to close the window, but I don't think that's gonna do the trick in all mobile devices.
My code:
$( document ).bind('pageinit', function(){
$.mobile.activePage.find('#close').click(function(){
window.open('', '_self', '');
window.close();
});
});
I'm using jQuery mobile.
Setup a custom URI handler (for Android and for iOS). Then all you have to do is redirect to a URL that matches, perhaps using window.location.
It seems that there are security restrictions that wouldn't allow you to close the window via JavaScript. See here
EDIT: You basically have two options: implement a custom URL handler for each platform you're developing for; or embedding a web view into your application (UIWebView for iOS or WebView for Android).
On iOS if you launch Safari from your app you won't be able to get back to your app after Safari closes, unless your app is registered as a custom URL handler and the page you are on launches a URL that launches your app.
On iOS if instead of launching Safari you show the web page in a UIWebView you have control over exiting the page.

Categories