URL Scheme Handling


The Xen HTML API allows you to launch arbitrary URLs from your widgets, including opening webpages in Safari, or invoking custom URL Schemes made available by user applications.


The usage of this is simple: set a new URL to window.location at runtime, which is the same as if you were to change the current page.


The following shows how to open https://apple.com in Safari:

 * Example function to open a URL in the Safari app
 * @param url The URL to open
openSafari(url) {
    // This is where the URL is actually launched
    window.location = url;

// Elsewhere in your code

You can use an identical approach for URL schemes, such as opening the Twitter app to a user:

window.location = 'twitter://user?screen_name=_Matchstic';

Additionally, this works with <a> tags too. Simply set the URL as the href property:

<a href="https://apple.com">
<a href="twitter://user?screen_name=_Matchstic">

result-matching ""

    No results matching ""