Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I detect if window.location failed?

How do I check if a call to window.location failed because the given URL was invalid, etc? Is there some event I can set on the window object or on some other object that can catch this?

like image 484
Sagi Mann Avatar asked Aug 23 '13 13:08

Sagi Mann


People also ask

How to enable/disable always detect my location in weather on win 10?

Steps to enable/disable Always detect my location in Weather on Win 10: 1 Step 1: Access Weather from the Start Menu. 2 Step 2: Click the Settings option on the left menu, and then select Always detect my location or Default Location. More ...

What is the use of window location?

Window Location. The window.location object can be written without the window prefix. Some examples: window.location.href returns the href (URL) of the current page. window.location.hostname returns the domain name of the web host.

How to check the status of an issue in Windows 10?

I would suggest you to try to set the location to check the status of the issue. Follow the steps. 1. Go to the Control Panel then try to search for region then in region tab click on location. 2. Try to select the location. 3.

How do I disable the program to detect my position?

Supposing that you want to protect your privacy, you can disallow the program to detect your position according to the guidance below. Step 1: Access Weather from the Start Menu. Step 2: Click the Settings option on the left menu, and then select Always detect my location or Default Location.


1 Answers

Finally got it to work using a "workaround" that is not a generic solution as I originally hoped:

I am using the fact that the link I am trying to open is a custom url scheme (e.g. myxx://localhost) on mobile, and if it fails, the action I want to perform is a redirection to a standard appstore URL (os-specific). The workaround tries to open the custom URL, and if it fails, the timeout function kicks in shortly after, and opens an alternative url:

setTimeout(function() { window.location=alternateUrl; }, 25);
window.location = customUrl;

The downside is that when the customURL fails, a standard safari browser shows a message box that the site could not be opened, but at least it still redirects the user to the appstore.

like image 123
Sagi Mann Avatar answered Sep 28 '22 06:09

Sagi Mann