HTML
  Home arrow HTML arrow Page 4 - The power of DIV with IFRAME
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

The power of DIV with IFRAME
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 28
    2006-03-08

    Table of Contents:
  • The power of DIV with IFRAME
  • Using a DIV as variable to write into IFRAME: discussion
  • Making DIV more dynamic to write into IFRAME
  • Creating your own library to write dynamic content to IFRAME: essentials
  • Creating your own library to write dynamic content to IFRAME: utility functions

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    The power of DIV with IFRAME - Creating your own library to write dynamic content to IFRAME: essentials


    (Page 4 of 5 )

    This is one of the more difficult tasks to work with.  In this article, I try to help you “only a little” to write your own library to work with IFRAME.  As you know, there always exists a chance to extend/enhance the same according to your needs.  I will also try to use the concept of Objects in JavaScript now.

    I start with a simple function as follows:

    function IFrameBox(id, varName, width, height, url, msg)
    {
          this.id = id;
          this.DivID = "IFrameDiv";
          this.Width = width;
          this.Height = height;
          this.VarName = varName;
          this.timeout_id = null;
          this.IFrameUrl = url;
          this.IFrame = document.getElementById(this.id);
          this.RenderContent();
          this.Show();
          this.Hide();
    }

    The above function simply works like a class with a constructor having six parameters.  You can use the above class with a declaration as follows:

    var IframeBox = new IFrameBox("frIFrame", "IframeBox", 147, 207)

    The “frIFrame” is nothing but your own IFRAME declared within your HTML.  You can retrieve the document of a frame using the following function (including the browser hacks):

    IFrameBox.prototype.GetIFrameDocument = function()
    {
          var doc;
          if( this.IFrame.contentDocument )
                // For NS6
                doc = this.IFrame.contentDocument; 
          else if( this.IFrame.contentWindow ) 
                // For IE5.5 and IE6
                doc = this.IFrame.contentWindow.document;
          else if( this.IFrame.document )
                // For IE5
                doc = this.IFrame.document;
          else //other browser
                doc = this.IFrame.document;     

          return doc;
    }

    You can simply write any information into the IFRAME using a function similar to the following:

    IFrameBox.prototype.RenderContent = function(msg)
    {
          var doc = this.GetIFrameDocument();     

          var style = " style='Background-Color: #aad5ff; FONT-FAMILY: Verdana; FONT-SIZE: 8pt; BORDER: #336699 1px solid; POSITION: absolute;' ";     

          doc.open();
          doc.writeln("<body style='Margin: 0px;'>");
          doc.writeln("   <div id='" + this.DivID + "' align=center " + style + ">");
          doc.writeln("   </div>");
          doc.writeln("</body>");
          doc.close();
    }

    More HTML Articles
    More By Jagadish Chaterjee


       · Hello guys! A fine introduction on using DIV with IFRAME. enjoy and give any...
       · I tried this tutorial but it didn't work in firefox. what are the firefox work...
     

    HTML ARTICLES

    - Sorting for Database Forms with HTML
    - Edit and Other Database Form Functions with ...
    - More Database Form Functions with HTML
    - Database Form Functions with HTML
    - Using the HTML Table Element as a Recordset
    - Building Single Row Database Forms with HTML
    - Introduction to Database Forms with HTML
    - Another Look at Animation of Geographical Ma...
    - Animation of Geographical Map Regions
    - Changing and Moving Pictures with CSS
    - Clickable Geographical Map Regions
    - Gradient Creation with the HR Element
    - Text on HTML Images: Do it Yourself
    - Custom Buttons in HTML
    - Quick Web Page Menu







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway