ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

HTML: iframes

Updated on September 9, 2012

Iframes: is a flexible html solution for placing content into inline boxes within a single web page any where on that page. You use it to embed content from other html documents, or even display an entire page from another site.

It’s a pretty good solution to allow some interaction with the user, without having to reload the entire page. You could have a contact us form within an iframe, and only the section of the page will reload when submitted. You could use an iframe to load content that is scrollable, allowing the user’s page to sit static, while just that section of the page interacts with the user.

One major disadvantage of frames and iFrames is search engine indexing these pages. Search engines have a hard time corresponding the main concept of the web page to the documents or content within the frames or iframes.

There is one solution to help with the search engine indexing the main page with the frames or iframes. It is the use of NOFRAMES meta tag. However, not all search engines utilize meta tags in your main page. The NOFRAMES meta tag, allows you to place content between the two tags to help search engines and even older browsers that may have an issue with frames or iframes.


Sample Usage For iFrames

- Displaying an image when the user clicks a link on the main page. Only the iframe will reload with every click. I realize there is javascript all over the web that could do the same. However, an iFrame might be a quicker solution.

- Changing the content infromation within an iFrame when the user clicks a link. You could have a menu selection of links down the left side of a page, and allowing the user to click a link, again without the entire page reloading. The content from the link clicked would only change within the small window or iFrame.

- Hide the url from where the web page is actually pulling from. The user thinks they are going to www.yoursite.com, but it's actually an iFrame, pulling content from another site.

- Displaying content from a form submitted. You could build a single web page with an iFrame, basically splitting the page vertically down the middle. When the user submits a form on the left side of the page, it changes the content with the iFrame on the right side. Again, not reloading the entire page.

- A menu selection could be displayed across the top of the main web page with links to other content pages, allowing the user to click any of the links, displaying content in the main body of the web page, and not changing the menu selection across the top. This will allow you to make changes and/or additions to the menu selections on your site, and not have to change or modify all the content pages, that would normally have the menu selection on it.

- It allows your web page to be displayed within the browser window, without a lot of scrolling up and down by the user. Basically, you could build a web page with multiple iFrames, displaying content, allowing just those windows or iFrames to scroll, keeping your entire page within the users browser window.

Sample 1: Links to display an image

In this example, you would have some links on the main page, when clicked would change the image within the iFrame window.

<li><a href="/images/image2.gif" target="imgbox">Image 2</a>
<li><a href="/images/image3.gif" target="imgbox">Image 3</a>
<li><a href="/images/image4.gif" target="imgbox">Image 4</a>



<iframe frameborder="0" scrolling="no" width="150" height="200"
   src="/images/default.gif" name="imgbox" id="imgbox">
</iframe>

Sample 2: Navigational Bar With Links

In this example, we will have a navigational menu across the top, with links to content pages within a single iFrame.

<table border=0 cellpadding=1 cellspacing=2 width=800>
<tr>
<td valign=top><a href="page1.html" target="mainframe">Page 1</a></td>
<td valign=top><a href="page2.html" target="mainframe">Page 2</a></td>
<td valign=top><a href="page3.html" target="mainframe">Page 3</a></td>
<td valign=top><a href="page4.html" target="mainframe">Page 4</a></td></tr>
</table>


<br><br>
<iframe name="mainframe" src="default_page.html" align="top" height="1000" width="480" hspace="0" vspace="0" frameborder="0" scrolling="auto">
</iframe>

CSS For iFrames

You can also change the look of the iFrame scrollbars and arrows with some css. Below is an example of some css that changes the look and feel of the iFrame scrollbars. Place this css within the page that is called within the iFrame. Insert the css code between the <head></head> tags.

<STYLE type="text/css">
BODY {
scrollbar-face-color: 3333cc;
scrollbar-base-color: 3333CC;
scrollbar-highlight-color: 000000;
scrollbar-3dlight-color: 000000;
scrollbar-darkshadow-color: 000000;
scrollbar-shadow-color: 000000;
scrollbar-arrow-color: FFFFFF;
scrollbar-track-color: ffffff; }
</STYLE>

iFrame Properties

- SRC: URL of the document to go in the frame
- NAME: name of the frame
- LONGDESC: URL of a long description of the contents of the frame
- FRAMEBORDER: if the frame should have a border
- WIDTH: width of the frame
- HEIGHT: height of the frame
- MARGINWIDTH: internal left and right margin for the frame
- MARGINHEIGHT: internal top and bottom margin for the frame
- SCROLLING: if the iframe should have scroll bars
- ALIGN: alignment of the frame object to text around it
- VSPACE: space above and below the frame
- HSPACE: space to the left and right of the frame

Summary

In summary, iframes can help a great deal in the layout of your web page. I perfer iFrames than framesets. To me, it's much an easier set-up.

Check out my article on HTML Tables.

working

This website uses cookies

As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://corp.maven.io/privacy-policy

Show Details
Necessary
HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
LoginThis is necessary to sign in to the HubPages Service.
Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
AkismetThis is used to detect comment spam. (Privacy Policy)
HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
Features
Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
MavenThis supports the Maven widget and search functionality. (Privacy Policy)
Marketing
Google AdSenseThis is an ad network. (Privacy Policy)
Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
Index ExchangeThis is an ad network. (Privacy Policy)
SovrnThis is an ad network. (Privacy Policy)
Facebook AdsThis is an ad network. (Privacy Policy)
Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
AppNexusThis is an ad network. (Privacy Policy)
OpenxThis is an ad network. (Privacy Policy)
Rubicon ProjectThis is an ad network. (Privacy Policy)
TripleLiftThis is an ad network. (Privacy Policy)
Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
Statistics
Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
ClickscoThis is a data management platform studying reader behavior (Privacy Policy)