views:

1283

answers:

1

I have to develop a widget that will be used by a third party site. This is not an application to be deployed in a social networking site. I can give the site guys a link to be used as the src of an iframe or I can develop it as a JavaScript request.

Can someone please tell me the trade offs between the 2 approaches(IFrame versus JS)?

A: 

Nice to know that it's not to be deployed in a social networking site... that merely leaves the rest of the web ;-)

What would be most useful depends on your widget. IFrames and javascript generally serve quite different purposes, and can be mixed (i.e. javascript inside an iframe, or javascript creating an iframe).

  • IFrames got sizing issues; if it's supposed to be an exact fit to the page, do you know that it renders the same on all browsers, the data won't overflow it's container etc?
  • IFrames are simple. They can be a simple, static HTML-page.
  • When using IFrames, you expose your widget quite plainly.
  • But then again, why not have your third party site simply include the HMTL at a given url? The HTML can then be extended to contain javascript when/if you need it.
  • Pure Javascript allows for more flexibility but at the cost of some complexity.