I would like for someone to explain the reason that Google's Gmail is placed inside of an iFrame HTML element instead of simply placing the code in the document itself.


According to the Gmail blog, an iFrame is used to host the code which handles gmail so that messages opened in new windows can be used without having to reload resources, and can persist even if the parent window is closed. See this blog post for some more details on how it works.

For the technically curious among you, our friends on the Chrome team made it possible to transfer the code that runs Gmail from one window to another as the window closes. When the window that hosts the code fires an unload event, we move the iframe with the code to a surviving window. Everything continues to run, including timers and outstanding requests.


I'm not sure myself - but my guess is that it would be because it fixes some javascript or css bugs / limitations.


Is it inside an Iframe irrespective of what browser is being used? There might be number of reasons for that, starting from a hack ( oh no god forbid ) , to having in IFrame when servicing to some specific browsers issues as Samuel Walker said in his answer.

What is the source of IFrame? It might be that there is no deeper reason for it being in the IFrame and if you use some firefox extensions you can see the document outside of the IFrame. Just try browsing the real documents location and see what changes, that might be the answer to why they are using IFrame.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.