Skip to content

Instantly share code, notes, and snippets.

@benmay
Created April 24, 2013 06:16

Revisions

  1. benmay created this gist Apr 24, 2013.
    15 changes: 15 additions & 0 deletions js-cookies.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    jQuery(document).ready(function($)
    {
    var deviceAgent = navigator.userAgent.toLowerCase();
    var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
    if (agentID)
    {
    if( $.cookie('my_cookie_name') == undefined )
    {
    $.cookie( 'my_cookie_name', 'true', { expires: 30 });
    if ( confirm( "You're on an mobile device, you should download our app." ) ) {
    window.location = 'https://itunes.apple.com/....';
    }
    }
    }
    });