I have iframe (cross domain) with src from Facebook, Twitter or etc.
I need to get height of iframe but I got error:
Permission denied to access property ‘document’
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Couple issues. First, the height of the
iframeis likely not what you want. I mean that’s set explicitly in the HTML code of the page you control and is readily accessible and modifiable through any Javascript means. What it appears you are after is the height of the page inside the iframe. If that’s the case, the simple answer is you can’t, at least not with external services like Facebook/Twitter.Due to security reasons, one can easily pass messages from child to parent, but not from parent to child, unless a communication pathway has been built into your javascript in both documents. There is a
postMessageprotocol for handling this in modern browsers. https://developer.mozilla.org/en/DOM/window.postMessage . But, it’s wholly useless in this case unless the document you are communicating with is setup to handle an incoming postMessage, which to my knowledge Twitter/Facebook frequently are not.If a parent document could freely communicate with children from different domains, then any javascript could effectively execute any series of commands on any site you’re logged in as. The security implications of that are frightening and thankfully not possible.