Override "Safari cannot open the page because the address is invalid" - javascript

Does anyone know if its possible to override this dialog on ios safari when trying to open a native app from the safari browser using a URI appname:/// and the app is not installed on a device?
I tried overriding the window.alert and it works as expected for browser alerts, however it does not work when this pops up. Or does this maybe fire some event that I can listen for using window.addEventListener()?

Related

React Kiosk app on Google Chrome crashes on multi touch input

We have a Kiosk App (written in React) and it is working on ~800 devices. All of the devices are Windows devices and for some of them (about 5%), when a user without tech literacy uses more than one finger (lets say he tries to input his customer number but with using three fingers instead of one) the app crashes after a point (Google Chrome is not responding error).
I do not know why, but when I tried to debug the app on live environment using localhost:9222 as my Chrome DevTools output, I could raise some errors while scrolling and clicking the app, but I cannot create the user input remotely, because I am using a mouse, not a touch screen. And I cannot debug on the devices.
Does anybody have an idea on what is wrong? And how can I stop the crashes?
What I tried to do so far;
Tried to enable Crash Logs, couldn't make it log to a file so I can inspect it, nothing gets logged
Tried to create a chrome console log file, but nothing is shown here too
Tried to change screen input type from touch to mouse click, didn't fix it
Tried to use Chrome Command Line Switches such as disable-pinch and enable-crash-reporter but none of them seem to give me any info or fix the problem
Any tips?

Open links in main Safari browser instead of WebView - PWA (iOS)

I send an email with a link of my PWA website.
When I click on the link and say open with Safari it opens in the Safari webview.
The Safari webview however does not have an add to homescreen option like the native Safari browser does.
When I open the link with my native safari browser I get the ability to add to homescreen.
What can I do to open the link directly in the native Safari browser instead of the webview.
Alternatively is there a way to find out that I am in the webview instead of the native Safari browser to prompt the user accordingly?
Currently testing on iOS 14.2
You are using the Gmail App to open the link so it is prompting you which browser that you want to open the link with.
To open the link directly into the Safari browser instead of the webview (assuming you have it set as your default browser under Settings), click on the "Default browser app" option below the Safari option.
It is currently not possible to detect and prompt the user accordingly, however you could play around with window.navigator.standalone to detect if the user is in the PWA or not.

How to show confirm dialog before page reload on iOS using javascript in 2016?

Could anyone explain me how to show confirm dialog on page refresh on iOS devices?
We use window.onbeforeunload handler on desktop, it works fine and as we expect. But the problem was found when we tried to check hot it works on iOS devices.
I found a lot of information here about pagehide and unload events, and that they work fine on iOS devices, but all my attempts was failed.
Please, help me and provide working code example. (I'm testing app on iPad Air 2, iOS 9.3.2).

iPad Safari Popup issue

On iPad Safari, there seems to be issue with popup. When a popup (opened using window.open()) is closed, it remains in minimized mode (or grid view) after closing the popup...It
does not return focus to the parent window.
I have tried using parent.opener.focus(), but still does not work.
Is this a known iPad issue OR can we fix this issue using some JS code?
Please help.
I'm not sure if this would help, but just some personal experience on this issue:
Did you try going to iPad's Setting - Safari - Block Pop-ups? Try turning off Block Pop-ups, it should work.
If it still doesn't appear, try turning on the Debug Console for the ipad and check if any error appears during the popup event.
Try using a URL for window.open to be a local / same domain url address. I think that works (without needing to turn off the popup blocker in safari ipad).

can javascript detect if android browser is in foreground or background?

I have this HTML.<html><body>
PLAY ME!!!!!
</body></html> So if somebody clicks on the link then native media player loads and browser goes into background and when video ends it comes to foreground with the same page. Is there a way to detect this i.e. browser going background and then coming foreground in the javascript?
Android Chrome has the visibilitychange event; example code is here: http://output.jsbin.com/rinece
To test:
on Android Chrome open that link
Either
watch the log below the clear button and notice the delay times (so you can see exactly when the event occurred within the page).
or attach the debugger and watch the console
or if you can't attach the debugger (WebView or AOSP) then open http://output.jsbin.com/rinece#http://localhost:80/ and use a proxy or set up a localhost server that shows you the body content (the log text is in the body of the xmlhttp requests; change the # url to a proxy or server where so you can see the Requests occur).
Change tabs
Watch the log to confirm which events occur on visibilitychange
AOSP (and WebView for Android < 4.4) may have different behaviour than Chrome...
The visibilityChange event is now well supported on mobile - see http://caniuse.com/#search=visibility but beware that it is not supported by iOS UIWebView (even if on iOS9).
So as the article that #ndtreviv linked says that "Switching to another document or application." is not implemented in Android yet. However, you can, if you want to, make an app that uses a WebView to display your content. This way, you can access all the native Android stuff from JavaScript.
There is a proposal to allow mobile webapps to detect whether they are in the foreground or not, you can use the "visibilitychange" event, see here: http://www.w3.org/TR/2013/REC-page-visibility-20131029/#sec-visibilitychange-event
Note that this event is fired on the document, not on the window. E.g:
window.document.addEventListener("visibilitychange", function(e) {
window.console.log('VISIBILITY CHANGE', window.document.visibilityState);
});

Categories