Home arrow HTML arrow Page 5 - The power of DIV with IFRAME

The power of DIV with IFRAME

This article mainly explains the benefits of using DIV to write dynamic content to IFRAME. I shall also guide you in developing your own library of functions to work with IFRAME effectively.

Author Info:
By: Jagadish Chaterjee
Rating: 4 stars4 stars4 stars4 stars4 stars / 78
March 08, 2006
  1. · The power of DIV with IFRAME
  2. · Using a DIV as variable to write into IFRAME: discussion
  3. · Making DIV more dynamic to write into IFRAME
  4. · Creating your own library to write dynamic content to IFRAME: essentials
  5. · Creating your own library to write dynamic content to IFRAME: utility functions

print this article

The power of DIV with IFRAME - Creating your own library to write dynamic content to IFRAME: utility functions
(Page 5 of 5 )

The following function may be used to resize the IFRAME dynamically.

IFrameBox.prototype.Resize = function(wdth)
      if( IFrameBox.IsBrowserIE() )
            var div = frames[this.id].document.getElementById(this.DivID);
                  this.IFrame.style.width = div.offsetWidth;
                  this.IFrame.style.width = wdth;
            this.IFrame.style.height = div.offsetHeight;
            this.IFrame.style.width = this.Width;
            this.IFrame.style.height = this.Height;

The following function may be used to place an IFRAME at required positions on the web page:

IFrameBox.prototype.PlaceAt = function(x, y)
            this.IFrame.style.position = "absolute";
            this.IFrame.style.left = x;
            this.IFrame.style.top = y;

The following function tests whether the current IFRAME is in the visible state or not:

IFrameBox.prototype.IsVisible = function()
      var ifrm = document.getElementById(this.id);     

      if( ifrm.style.visibility == "visible" && ifrm.style.width > 0 )
            return true;
            return false;

The following function makes an IFRAME visible (make sure that it uses some of the functions defined above).

IFrameBox.prototype.Show = function(evt, msg, wdth)
      if( this.IsVisible() )

      var div = frames[this.id].document.getElementById(this.DivID);

            this.PlaceAt((evt.x +10),(evt.y +10));


      this.IFrame.style.visibility = "visible";
      this.IFrame.style.zIndex = "999999";

Hiding an IFRAME is the simplest of all. You can define the function as follows:

IFrameBox.prototype.Hide = function()
      this.IFrame.style.visibility = "hidden";
      this.IFrame.style.width = 0;
      this.IFrame.style.height = 0;

I leave it to the programmers to further extend the library to suit their needs.  The above set of functions is very suitable for presenting eye-catching tool tips on your web page.  As the tool tips are based on IFRAME, they are naturally displayed ahead of any windowed controls (like dropdown lists and so on).

Any comments, suggestions, ideas, improvements, bugs, errors, feedback etc. are highly appreciated at jag_chat@yahoo.com.

DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


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