Prevent my website from opening in other mobile apps Web View - javascript

When user is using an app, Facebook's app for example and click on my website link, my site will be opened in Facebook's app Webview.
I want to prevent that and open it in a browser instead.
Can I make it work by adding some javascript codes to my website ?

Try window.open() method of Javascript.

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!

Is there any way to force a link to open in Chrome from Facebook's in-app browser?

I've got a web app that requires the ability to print. Facebook's in-app implementation of Chrome doesn't allow printing. Currently, I'm giving the user instructions on how to open in chrome themselves in place of the print button I give normal users. But I'd prefer to just open Chrome for them when they get to that page, or at the very least provide a button/link that would open the page in Chrome instead of forcing them to find the settings button and figure out how to open Chrome themselves.
I've tried using the googlechrome://myurl.com approach, and Chrome opens, but the specified url doesn't load.
I've looked into Google's Intent option but I wasn't able to figure out how to open Chrome with that method.
Is there a way to accomplish this in javascript? or by some url scheme in an href attribute?
So far, all the other answers I've found give explanations for how to do this from an Android App, but not from a website.
** Update: The googlechrome://myurl.com seems to work fine from iOS in the native facebook app. It does not appear to work correctly using the native facebook app in Android.
Try
googlechrome://navigate?url=example.com
for Android users.
Reference from https://stackoverflow.com/a/12013755/9514189

Opening Up Facebook app outside Facebook

I have a web app which I am loading in Facebook iframes. The thing is my app opens File Picker which sends backs the data form where it was loaded. But if my web app is inside an iframe it doesn't allow File picker to communicate back due to security reasons.
So what I am doing it when the users on my FB page click on my app I take them out of the facebook and open my web app in browser. This thing works perfectly in Android or on my Windows. But in Iphone it doesn't takes the app outside and doesn't open it in the browser.
Do you know why? Is there a solution for it?
Seems the problem is a security feature of the browser's popup blocker.
It treats the window as a popup if it occurs outside of the callback of a user interaction.
It therefore gets buckets as a popup and blocked.
Unfortunately, iOS Safari gives absolutely no indication of this, making the issue difficult to track down.

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