IFRAME autoresize and a secure way to transfer information from one domain to another

    As you know, when working with frames for security, browsers do not allow JavaScript code to access from the page of one domain to the page of another domain. In this short article, we will consider aspects of cross-domain work in JavaScript, describe one of the “good” special cases, and in the end I hope to get answers to the remaining questions in the Habracomment.

    UPD1: those who are here for the first time - be sure to read the comments on this article, they threw a lot of interesting things (as I hoped). Thanks!

    UPD2: found a solution to the autoresize problem for everything except Opera <10.

    UPD3:a fully cross-browser solution to the resize task is given below. Its features: a) history does not spoil, b) works even in Opera 7 and IE6, c) to speed up the frame height is always made a multiple of N = 30 pixels. In fact, there are 2 algorithms - for IE (via location.hash) and for “non-IE” (through window.name and “tapping” the possible heights in the loop). See also comments on the article, for explanations of why this is and not otherwise.

    UPD4: the article began to take on monumental features, so it moved to me in Nabla on dkLab: dklab.ru/chicken/nablas/58.html - there are all the code examples of the latest relevance. But, of course, in case of changes, I will announce them here too, adding UPD5, UPD6, etc.

    Also popular now: