Created
November 3, 2012 06:47
-
-
Save keichan34/4006333 to your computer and use it in GitHub Desktop.
Enable #links in Facebook Canvas
This file contains 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 characters
/* | |
anchorlinks-fbcanvas.js | |
Enables anchor links (<a href="#hello">Go to id="hello"</a>) in | |
Facebook Canvas (page tabs, canvas app, etc) | |
Requires: jQuery, Facebook JS SDK | |
*/ | |
jQuery(function($) { | |
$('a').filter(function() { | |
return $(this).attr('href').match(/^#/); | |
}).each(function(i, el) { | |
$(el).click(function(e) { | |
e.preventDefault(); | |
var elementId = $(el).attr('href').replace(/^#(.*)/, '$1'); | |
var $goTo = $(document.getElementById(elementId)); | |
FB.Canvas.scrollTo(0, $goTo.offset().top); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment