I haven't had the chance to work with JavaScript on Facebook, so I can only make an educated assumption.
It seems likely that Facebook runs your JavaScript in a secure iframe
sandbox environment. After a quick search on Google, it appears that they may preprocess your code to remove potential security risks and limit access to certain DOM APIs.
With this in mind, it's possible that your code isn't working for two main reasons:
- Your use of the
document
object might be restricted for security purposes, leading to its removal or some form of deactivation in the sanitized script.
- The
document
likely refers to the HTMLDocument
displayed in the iframe
where your JavaScript runs. This means that height
would pertain to the iframe
's height, not the entire Facebook page as you may have expected.
Have you checked if any Facebook developer tools could assist you? Are there any errors showing up in your console?