ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Embeding content on your web pages -- iframes vs native content?

<< < (2/3) > >>

PPLandry:
If the content formatting does not contain any CSS specific styles, putting the content inside a <div> </div> works quite well, and it does auto-size correctly (unlike iframe)

FYI, one way to auto-size iframes, it is to run a script to size it once loaded, setting the height property to the document height

Veign:
You can't embed content in a DIV from a 3rd party website.

mouser,
Are you looking to get analytics from the page its being embedded on?  Are you interacting with the host page in any way?  Does an iframe version work the same as the more complex JS version?

mouser:
Are you looking to get analytics from the page its being embedded on?  Are you interacting with the host page in any way?  Does an iframe version work the same as the more complex JS version?
--- End quote ---

i'm actually pretty proud of how i coded it -- i created code to render the results which is shared between both the server script and the local script.  the server code is actually driven by a drupal cms, but the rendering code has no drupal specific stuff.  part of why i did that is so that the local widget script can interact with the data in various ways as well (ie. pagination, etc.) -- it's not just grabbing and caching a simple html contents page.

if the user wants to use iframe version they just use that (and i can even have a lightweight non-drupal server script create the data from the request).

if the user wants to use a non-iframe local widget, then the rendering code is invoked by a local script on the machine serving up the page, using a kind of proxy cache that only periodically needs to get new data from the remote server.  i make use of several mechanisms to keep bandwidth minimum until content actually changes (i use Conditional Get and keep track of when data has changed, etc.).

part of why i've gone to so much trouble to avoid an iframe solution is that this is meant to be something that could theoretically be on huge numbers of pages serving of a huge amount of bandwidth constantly, and using an iframe solution would mean that my server would have to fulfill all of those requests live.  the way i have it now it's almost no bandwidth/cpu at all on the main remote server -- just the occasional query to ask whether the cached content has changed (and the answer is almost always no).

the cache proxy system also downloads and replicates image files automatically since some of the widget content refers to images on the main server, which again i don't want to have to bear the burden of serving up.

one major advantage of this over iframes is that the widget will work fine if the main server goes does completely.. it simply serves up the last good cached version of the data.

ps.
there is an existing php script that does a fair amount of what my code does and is pretty generic; it doesn't do conditional get but it's otherwise pretty good: http://www.troywolf.com/articles/php/class_http/  you'll also find that some rss widget scripts do a similar thing regarding caching, which let's them solve the "same origin policy" security lockdown on webpage javascript (which is a pain in the ass and clearly not stopping anyone from doing this, just making it harder).

PPLandry:
You can't embed content in a DIV from a 3rd party website.
-Veign (July 28, 2010, 06:05 PM)
--- End quote ---

Absolutely true, my mistake  :-[

Veign:
@mouser - good explanation.  Once I get to the point of moving forward with a JS version (for the same benefits you described) I will be in contact

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version