cross-domain iframe resize
The thing is - there is no other way than using Cross-Domain Messaging for this since you need to get the computed height from a document in one domain, to a document in a different domain.
So, either you do this using postMessage
(works in all moder browsers), or you spend 5 minutes adapting the resize iframe example from easyXDM.
The other party really just needs to copy a few files onto their domain, and add a single line of code to their document..
How can I resize a cross-domain iFrame that I do not have control over
Based on the comments I received, it seems safe to say that it is impossible to re-size a cross-domain iFrame from the client/browser side.
Perhaps some complex server-side algorithm could request the page and attempt to give hints about the size, but nothing can be done on the client-side.
How to get height of iframe cross domain
Couple issues. First, the height of the iframe
is 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 postMessage
protocol 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.
Related Topics
Python Library for Rendering HTML and JavaScript
Angular2 Router 2.0.0 Not Reloading Components When Same Url Loaded with Different Parameters
How to Disable the Save Password Bubble in Chrome Using JavaScript
When Using Jquery On(), Why Use (Document) VS. the Element Itself
Call Python Function from JavaScript Code
Converting Milliseconds to a Date (Jquery/Javascript)
Why Is Arr = [] Faster Than Arr = New Array
Mongoose - What Does the Exec Function Do
Uncaught Syntaxerror: Unexpected Token :
Why Are CSS Animations and Transitions Blocked by JavaScript
Why Browser Is Returning Empty String on Style.Height ? How to Get Actual Height of an Element
Jquery CSS Rendering - Works in Firefox, Not in Chrome
External CSS Styles Cant Be Accessed in Google Chrome
Jquery How to Apply CSS to Selected Text
Draw a Circle Around Nodes Groups
JavaScript Equivalent of Ruby's String#Scan
How to Declare Hash.New(0) with 0 Default Value for Counting Objects in JavaScript