Home arrow HTML arrow Page 3 - The Ins and Outs of Iframes
HTML

The Ins and Outs of Iframes


The term "iframes" is short for "inline frames." Maybe you have never heard of iframes, or maybe you have avoided them because the name incorporates the "F" word, i.e. "frames," which are said to do bad things like confuse search engines. If so, this article will introduce you to a very useful and versatile web design tool that you have been missing out on. If you have already used iframes, but for only basic things, this article will show you some powerful new uses, such as remote scripting.

Author Info:
By: John Best
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
December 15, 2008
TABLE OF CONTENTS:
  1. · The Ins and Outs of Iframes
  2. · iframes Questions and Answers
  3. · Uses of iframes
  4. · iframe Uses continued

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
The Ins and Outs of Iframes - Uses of iframes
(Page 3 of 4 )

The simplest use of an iframe is to merely display a static page located on the same server, for example:

<iframe src ="/path/mypage.html" width="100%"></iframe>

Not too exciting, right? Well, let's learn about some more interesting uses. To aid the discussion, we will talk about the web site of the fan club for the Webtown Wizards, my buddy Joe's favorite football club (it is imaginary, and so is Joe).

Joe is the webmaster of the Wizards Fans website, and he wanted to add something to make the blog page more interesting, so he added an iframe containing the home page of somesportsite.com (imaginary, I think). The somesportsite.com page had a score box so the fans could check out the score of the game while they write messages on the blog. The score box was the only area of the page that they were actually interested in.

<iframe src ="http://www.somesportsite.com" width="100%"></iframe>

This was a nice addition, but it was inconvenient to use. There was only room on the Wizards blog page for a 500px by 300px iframe, but somesportsite.com was a full-size web page. This meant that the iframe had scrollbars, and since the score box was located near the middle of the somesportsite.com page, a lot of scrolling was required to reach it. What Joe really wanted was to have only the score box from the somesportsite.com page display in the iframe. This is how he achieved it.

Displaying an Area of a Page in an iframe

The first thing Joe did was create a page called iframedemo.html. He then placed the iframe tag on the page. He made sure that it had a name attribute, knowing he would need it.

<iframe name="scorebox" src="http://dummypage.html" width="500" height="300" frameborder="0" scrolling="no" marginwidth="0" marginheight="0">

</iframe>

Making the iframe the same size as the score box (500 x 300), was easy using the width and height attributes. The problem Joe needed to overcome was that the iframe displayed the upper-left corner of the somesportsite.com page by default, but the score box was in the middle of the page. How could he move the area displayed by the iframe down to where the score box was?

What he did to solve this problem could more accurately be thought of as moving the somesportsite.com page underneath the area displayed in the iframe until the score box is visible.


blog comments powered by Disqus
HTML ARTICLES

- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5
- BBC Adopts HTML 5, Mozilla Addresses Issues
- Advanced Sticky Footers in HTML and CSS
- HTML and CSS Sticky Footers
- Strategy Analytics Predicts HTML5 Phones to ...
- HTML5 Guidelines for Web Developers
- Learning HTML5 Game Programming
- More Engaging CSS3 and HTML Background Effec...
- Engaging HTML and CSS3 Background Effects
- More Web Columns with CSS3 and HTML
- Columns with CSS3 and HTML
- Creating Inline-Block HTML Elements with CSS
- Drag and Drop in HTML5: Parsing Local Files

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials