David
David

Reputation: 113

Why use iframes for dynamic content

Ok - really dumb question alert:

Why do all the new web apps and services use iframes for adding content to pages?

They all do it - facebook, twitter, gmail, disqus etc etc.

The only reasons I can think of are: - It prevents users from messing about with the behaviour and style of the elements inside it - it stops the elements inside from messing up any markup already on the page

Are there any other reasons for this and what are the alternatives?

Upvotes: 3

Views: 321

Answers (3)

silkcom
silkcom

Reputation: 502

Another reason to use iframes when submitting content is that iframes allow you to have multicontent forms with ajax. For example images or videos and text.

Upvotes: 0

jujule
jujule

Reputation: 11521

using iframes, you're almost sure of the final visual aspect as it doesnt interefere with user css/js... and it isolate the widget from the website environnement.

It may be much more complicated to embed a custom javascript, due to cross domains restrictions also.

Upvotes: 0

Julio Santos
Julio Santos

Reputation: 3895

Besides your reason (which is a rather relevant one), iframes are used to perform cross-domain requests safely.

Tweeting by using Ajax to POST from your domain to twitter.com won't work — the browser just won't allow it.

Upvotes: 1

Related Questions