Reputation: 504
I would like to assign document.height to the variable H
, how can I accomplish this?
var H = document.height;
var p = { width: 520, height: H };
FB.Canvas.setSize(p);
How would I do this in javascript? Was it correct expression height: H
? It didn't work.
Upvotes: 0
Views: 208
Reputation: 9703
I've never written any JavaScript for Facebook, so what follows is an educated guess.
Facebook are probably running your JavaScript within an iframe
sandbox for security reasons. A brief look at Google results also seems to suggest that they pre-process your code before running it, to "sanitize" it by removing security issues, access to banned DOM APIs etc.
Given this reasonable assumption, two reasons why your code is not working come to mind:
document
object is banned for security reasons, so removed from your sanitized script or disabled in some way.document
refers to the HTMLDocument
rendered in the iframe
within which your JavaScript is running, in which case height
will be the height of this iframe
, not the entire Facebook page as you are probably expecting.Do any Facebook developer tools help here? Are there any errors logged in your console?
Upvotes: 0
Reputation: 43265
If :
alert(typeof(document.height));
alerts "number";
Your code should work fine.
Upvotes: 1