Forked from ChaseFlorell/uriSchemeWithHyperlinkFallback.js
Last active
December 2, 2022 04:50
Revisions
-
kmallea revised this gist
Oct 1, 2013 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ -
kmallea revised this gist
Oct 1, 2013 . 1 changed file with 2 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,22 +1,6 @@ // tries to execute the uri:scheme function uriSchemeWithHyperlinkFallback(uri, href) { if(!window.open(uri)){ window.location = href; } } -
ChaseFlorell revised this gist
May 2, 2013 . 2 changed files with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ function uriSchemeWithHyperlinkFallback(e,t){var n=(new Date).getTime(),r,i;document.location=e;r=(new Date).getTime();i=r-n;if(i<1){document.location=t}} This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ <html> <head> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="uriSchemeWithHyperlinkFallback.min.js"></script> </head> <body> <!-- links will work as expected where javascript is disabled--> -
ChaseFlorell revised this gist
May 2, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,4 +19,4 @@ function uriSchemeWithHyperlinkFallback(uri, href) { if (elapsed < 1) { document.location = href; } } -
ChaseFlorell revised this gist
May 2, 2013 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ // tries to execute the uri:scheme function uriSchemeWithHyperlinkFallback(uri, href) { // set up a timer and start it var start = new Date().getTime(), end, elapsed; // attempt to redirect to the uri:scheme // the lovely thing about javascript is that it's single threadded. -
ChaseFlorell revised this gist
May 2, 2013 . 1 changed file with 17 additions and 17 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,22 +1,22 @@ // tries to execute the uri:scheme function uriSchemeWithHyperlinkFallback(uri, href) { var start, end, elapsed; // start a timer start = new Date().getTime(); // attempt to redirect to the uri:scheme // the lovely thing about javascript is that it's single threadded. // if this WORKS, it'll stutter for a split second, causing the timer to be off document.location = uri; // end timer end = new Date().getTime(); elapsed = (end - start); // if there's no elapsed time, then the scheme didn't fire, and we head to the url. if (elapsed < 1) { document.location = href; } }; -
ChaseFlorell revised this gist
May 2, 2013 . 2 changed files with 10 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,3 @@ // tries to execute the uri:scheme function uriSchemeWithHyperlinkFallback(uri, href) { var start, end, elapsed; @@ -21,14 +19,4 @@ if (elapsed < 1) { document.location = href; } }; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,5 +8,14 @@ <a class="intent" href="http://facebook.com/someProfile" data-scheme="fb://profile/10000">facebook</a> <script> // `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(); }); </script> </body> </html> -
ChaseFlorell renamed this gist
Mar 8, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ChaseFlorell created this gist
Mar 8, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ <html> <head> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="uriSchemeWithHyperlinkFallback.js"></script> </head> <body> <!-- links will work as expected where javascript is disabled--> <a class="intent" href="http://facebook.com/someProfile" data-scheme="fb://profile/10000">facebook</a> </body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ (function () { // tries to execute the uri:scheme function uriSchemeWithHyperlinkFallback(uri, href) { var start, end, elapsed; // start a timer start = new Date().getTime(); // attempt to redirect to the uri:scheme // the lovely thing about javascript is that it's single threadded. // if this WORKS, it'll stutter for a split second, causing the timer to be off document.location = uri; // end timer end = new Date().getTime(); elapsed = (end - start); // if there's no elapsed time, then the scheme didn't fire, and we head to the url. if (elapsed < 1) { document.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(); }); })();