Recently I was checking our web site with the validator available at W3’s Web and Mobile Devices. This validator reveals how compliant web pages are for displaying their content on mobile devices. I discovered that the one area where most of our pages failed was concerning the use of iframes. An iframe is an HTML tag that creates a frame or box for displaying another document, such as web page. It seems that iframes are not universally supported mobile devices, except on those using the Safari and Opera browsers. So then the question needs to be asked, “What can be used in place of an iframe?”

One technique is to replace iframes with Server Side Includes (SSIs). SSIs are a feature available on Apache and ISS Servers and are often used to display the contents of a web page in one or more pages of a web site. They allow a webmaster to update multiple pages across his site by just modifying one single embedded page. A page can be embedded with either of these lines of code:


SSIs are not limited to displaying the contents of embedded files; they can do many more tasks including executing programs or displaying the time, date or environmental variables. You can determine if SSI is enabled on your server by creating and running a blank web page with the extension .shtml that contains this line of code:

which should display the local date and time. The .shtml extension tells the server to check the file for SSI commands.

If SSI is not enabled, you can manually enable on Apache servers by adding these lines to your .htaccess file:

AddType text/html .shtml
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes

SSI include commands can also be used in PHP and ASP. In an ASP.NET web application a server sides include can be accomplished in this manner:

<%
Response.WriteFile ("file.inc")
%>

And while SSI commands are limited to including files from only the local server (as a security precaution), the PHP include command allows pages to be loaded locally or from other websites. With PHP files can also be included using functions from the cURL library, as in this example:

 

For this to work, the cURL library must be enabled on your server.
These are some of the ways to eliminate the use iframes in web pages. Can you suggest other techniques?

For more information on server side includes see:
Webmaster’s Guide to Server Side Includes
Server Side Includes
IIS Server-Side Include Directives
ASP.NET Server-Side Include Directive Syntax