Reputation: 118922
I want to be able to load the Facebook API inside JSFiddle. This is my current attempt.
When I run:
window.fbAsyncInit = function() {
FB.init({
appId: 'event-test',
xfbml: true,
version: 'v2.5'
});
};
I get the following error:
Uncaught SecurityError: Failed to set the 'domain' property on 'Document': Assignment is forbidden for sandboxed iframes.(anonymous function) @ xd_arbiter.php?version=42:1
Is there any way I can get this working?
Upvotes: 3
Views: 2963
Reputation: 5237
I don't know much about the Facebook login API. However, I do understand why you are getting the error message.
If you were to put your code inside a file on your computer's hard drive without jsfiddle, it should work.
Short answer: There is no way to get this to work with your current setup on jsfiddle. You can try looking for an alternative Facebook API if Facebook has a different API available that does the same thing.
Long answer: Sandbox is an attribute that be assigned to the iframe tag for security measures for the parent page. JsFiddle uses sandbox to provide security to the parent page. Your fiddle results are loaded into an iframe that looks like this:
<iframe name="result" sandbox="allow-forms allow-popups allow-scripts allow-same-origin allow-modals" frameborder="0" src="//fiddle.jshell.net/casebash/j26bq6qf/11/show/"></iframe>
Facebook just doesn't want their API to run within a Sandboxed iframe.
Upvotes: 2