Skip to content

Instantly share code, notes, and snippets.

@gowthamsadasivam
Last active December 28, 2015 23:29
Show Gist options
  • Save gowthamsadasivam/7579322 to your computer and use it in GitHub Desktop.
Save gowthamsadasivam/7579322 to your computer and use it in GitHub Desktop.
Facebook tab app redirect for the canvas page using Javascript
<script type="text/javascript">
if (navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/)) {
//it's a mobile device check we're inside an iFrame or not
if (top == self) {
//Not in iFrame redirect to application URL
top.location = "https://www.facebook.com/MyPage/?sk=app_xxxxxxxxxxx&ref=ts";
}
} else {
//NOT a mobile device check we're inside an iFrame or not
if (top == self) {
//Not in iFrame redirect to application URL
top.location = "https://www.facebook.com/MyPage/app_xxxxxxxxxxx";
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment