Giter Site home page Giter Site logo

jquery.applink's Introduction

jquery.applink

Create links to native apps from mobile (or minor cases from desktop) browsers.

HTML links should have the web url as default, but you can add an alternate link using the registered app protocol to invoke apps like Facebook, Twitter, Foursquare, etc...

Example:

<a href="https://facebook.com/me" data-applink="fb://profile">My Facebook Profile</a>

Also, you can use it to share your page, like:

<a href="http://twitter.com/intent/tweet?url=<?php echo $url; ?>&amp;text=<?php echo urlencode($text); ?>" data-applink="twitter://post?url=<?php echo $url; ?>&amp;text=<?php echo urlencode($text); ?>">Share My Web in Twitter</a>

This action will try to open the Twitter mobile app, and if is not available, it will open the default share modal at browser.

You have a extended schemes list available at http://wiki.akosma.com/IPhone_URL_Schemes and http://handleopenurl.com/scheme

Plugin detects the target="_blank" tag attribute, but take care because the window will be open with javascript function window.open and can be blocked by browser.

To enable the plugin:

$(document).ready(function () {
    $('a[data-applink]').applink();
});

All options and default values:

$(document).ready(function () {
    $('a[data-applink]').applink({
        popup: 'auto', // disable/enable share popup created by plugin. If auto, only will be enabled to popupDomains domains
        popupDomains: 'twitter|facebook', // If "popup" option is auto, it will check this domains to open a domain or redirect to page
        desktop: false, // disable/enable native app check for no mobile devices
        data: 'applink' // load native links from data-XXXXXX attribute,
        timeout: 1500 // time in ms to detect app before launch HTTP link (only when is mobile and desktop is false)
    });
});

Also, if you are using this plugin to set native links to a large list, you can use the delegate function to get the best performance:

$(document).ready(function () {
    $('.links-list').applink({
        popup: 'auto', // disable/enable share popup created by plugin. If auto, only will be enabled to popupDomains domains
        popupDomains: 'twitter|facebook', // If "popup" option is auto, it will check this domains to open a domain or redirect to page
        desktop: false, // disable/enable native app check for no mobile devices
        delegate: 'a[data-applink]', // Delegate action into the parent element (default is null)
        data: 'applink' // load native links from data-XXXXXX attribute,
        timeout: 1500 // time in ms to detect app before launch HTTP link (only when is mobile and desktop is false)
    });
});

Enjoy!

jquery.applink's People

Contributors

eusonlito avatar

Watchers

James Cloos avatar Kristoff IBell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.