Is there a way to redirect from my Facebook canvas page to my external website? I have seen blogs and answers on stackoverflow forms:
<script> window.top.location = 'http://www.yoursite.com/'; </script>
Unfortunately, such solutions never work. I tried top.location.href, window.location and location.href and also nothing works. Has Facebook removed the redirect feature from javascript by parsing this code? Is there a way to redirect?
UPDATE What happens is that the webpage works as if there was never a javascript redirect command. And actually, when I look at the source code through firebug, I do not see javascript redirects.
UPDATE 2 . I get the following JavaScript errors on my canvas page when I try window.top.location = 'http://www.yoursite.com/'; and other options above. Facebook doesn't seem to allow access to global javascript variables for window, top or local location:
Uncaught ReferenceError: a217374027657_location is not defined Uncaught ReferenceError: a217374027657_window is not defined Uncaught ReferenceError: a217374027657_top is not defined
Interestingly, document.location = 'http://www.yoursite.com/'; It works in that there are no exceptions ... but, of course, the web page is not redirected.
UPDATE 3 . It revealed! Javascript redirects only work with iframes. I had to change the settings on the extended screen to use an iframe instead of FBML.
javascript redirect facebook facebook-javascript-sdk
at.
source share