FB App URLS

Change class name on click in jQuery

by m4xout

HTML

<a class="intent"   
    href="https://www.facebook.com/pg/playwavearts/"   
    data-scheme="fb://www.facebook.com/pg/playwavearts/">Special Link</a>
    
    
    <a href="https://www.facebook.com/pg/playwavearts/about/?ref=page_internal" class="large-screen">Standard</a>

JavaScript

alert( "ready!" );
// A $( document ).ready() block.
$( document ).ready(function() {
    alert( "ready! 2" );

    // tries to execute the uri:scheme
function uriSchemeWithHyperlinkFallback(uri, href) {
    if(!window.open(uri)){
        window.location = href;
    }
}

// `intent` is the class we're using to wire this up. Use whatever you like.
$('a.intent').on('click', function (event) {
    uriSchemeWithHyperlinkFallback($(this).data('scheme'), $(this).attr('href'));
    // we don't want the default browser behavior kicking in and screwing everything up.
    event.preventDefault();
});

    
});