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?

<< < (3/3)

olderthandirt101:
Word Press has an embed iframe plug-in available that allows resizing.Using iframes to embed anything that you wish the search bots to read is fruitless unless you add your own content such as a review, outside the iframe .
Cacheing your content in gzip format in your database is always a good idea to save bandwidth.Again,WP has a plugin for that also.
Using php plugins for images, sound, or video ,whether streaming from sites like Youtube or your own site server simplifies things.I have used FLV Gallery,Next Generation Gallery,Fancy Box and Multibox..Resizing has never been much of a problem esp. with embed codes. For example, FLV Gallery allows presizing of a single video with subsequent videos displayed as thumbnails just like on Youtube,all with a simple shortcode in a page or post .If your intention is to use it for a sidebar or widget then the global presize maximum width is 300px.

CWuestefeld:
On the web site that I'm responsible for at work, I'll go to the ends of the Earth to avoid an IFRAME. A client-side script to pull in content from a foreign site is slightly preferable, but still not good.

The thing is, I'm responsible for ensuring the security of my users. When retrieving IFRAME content from a foreign server, I'm surrendering all control to that foreign server, but my users don't know where it's coming from, nor how trustworthy they are.

The AJAX solution is better, because it's not taking raw HTML. But at a minimum, it's still a privacy exposure in that it reveals to the foreign server who my customers are, and what content they're interested in.

Of course the "do the right thing", wanting to protect my customers, is the main thing. But even if it were not, some of our customers have placed restrictions in our contract that prevent me from doing this. So when it does occur on our site, I need to have behavioral switches in our code to disable it for customers that won't allow it. And where it can be allowed, I need NDAs and indemnification from the foreign server to keep me and my customers safe.

My preferred solution is for you to give me a web service. I can call your service from our web servers, acting as a proxy for the user, and expecting back data as opposed to raw HTML. I can then embed that into the pages as I see fit, with a much greater feeling of safety.

Of course, your users may not be so exacting, or have so much to protect. But without knowing what content you'll be dealing with, who knows...

Codebyte:
Mouser,

To answer your original question concerning the much debated "iframe or direct content injection" topic, let me first begin by explaining my own personal experiences.

While at work, I use a total of 3 methods for content injection and asychronous javascript and xml (ajax) calls. The three methods include:
1. Getting a script by creating a new dom element and injecting it somewhere to the page  which forces the clients browser to go get the data. I use this method the most to call php scripts that handle content and echo out javascript. It's ideal for dealing with data clientside (nothing important like passwords etc) but still being able to use server side code because php has access to mysql which can cache your data among other endless possibilities.
2. the traditional ajax methods - creating a new httprequest. i rarely ever use this method anymore.
3. using a combo of YQL (Yahoo Query Language) and #1. - i use this approach the most to scrape data from any web page i need. Yahoo actually caches the results for you which result in faster data returns.

Now you'll notice that none of my methods include iframes. My personal opinion concerning iframes is that they are deprecated. Tons and tons of headaches are created by using methods that include iframes. When traversing the DOM, iframes create more work than necessary. On another note... Iframes are absolutely required when uploading files without reloading a clients browser.

It all depends on your objective... Let me propose an example:

You have a personalized dashboard system for when a customer/user logs in. They have the ability of customizing what "widgets" they want. One customer in particular specifies he wants te latest tweets to display in a beautifully skinned widget box that you've created. the only problem is that you need to get his tweets.

in this example, i would create a few javascript functions to execute when the page is rendering that show a loading bar, use method #1 to create a script element that calls a php file i created to check the last time this users tweets were grabbed. if less than 1 hr ago, i would use mysql to grab the cached tweets and eliminate the extra server connection to twitter (which is overloaded constantly and could result in a timeout or hang.) if the users tweets were grabbed more than 1 hr ago, php can use cURL to grab the new tweets from the server and echo out an object response using JSON so that you can populate the widget with the data the user needs in an easily accsssible manner.

Anyways, let me know if you have questions. I'm uncomfortable typing from my iPhone and can provide more help at a better hour tomorrow ;)

Navigation

[0] Message Index

[*] Previous page

Go to full version