HTML
  Home arrow HTML arrow 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  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM developerWorks
 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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    The power of DIV with IFRAME


    (Page 1 of 5 )

    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.

    All of the examples in this article (except for the ones in the last two sections) can be directly tested by simply copying and pasting all of the code in each section into any text file, saving it with the extension .HTM, and opening it using a browser.

    Using a DIV as variable to write into IFRAME

    I already introduced you to writing dynamic content with IFRAME using JavaScript in last week's article.  I strongly suggest you refer to the previous article, if you are new at using JavaScript with IFRAME.

    In this article, we shall focus on using DIV as a template of information to write to IFRAME.  To be frank, I got this technique from one of my friend and I really want to share the same with all of you.  I must congratulate him for coming up with such an innovative idea.

    Now, let us try to develop a simple script (JavaScript) which shows the technique of using DIV with IFRAME. The entire code for the sample is as follows:

    <html>
          <head>
                <meta  name=vs_targetSchema  content="http://schemas.microsoft.com/intellisense/ie5">
    <script  id="clientEventHandlersJS"  language="javascript">
    <!--
    function Show()
    {
          var tDiv = document.getElementById("dvSample");
            var FirstElement = tDiv.firstChild;
            var v = FirstElement.nodeValue;
            var tFrame = document.getElementById("myFrame");
            var doc = tFrame.contentDocument;
            if (doc == undefined || doc == null)
                doc = tFrame.contentWindow.document;
            doc.open();
            doc.write(v);
            doc.close();
          document.all.myFrame.style.visibility="visible";
    }

    function Button1_onclick() {
    Show();
    }
    //-->
                </script>
          </head>
    <body>
    <div  id="dvSample">
          <!--
            <html>
              <body>
                Hai, this is from Div!
              </body>
             </html>
           -->
        </div>
          <iframe  id="myFrame"  frameborder="0"  vspace="0"  hspace="0"  marginwidth="0"
    marginheight="0" width="100" scrolling=yes  height="100"
    style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; Z-INDEX: 999; LEFT: 20px; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid; POSITION: absolute; TOP: 100px; visibility:hidden;"></iframe>
                <form  id="form1">
                      <input  type="button"  value="Show"  id="Button1"  name="Button1"  onclick="return Button1_onclick()">
                </form>
          </body>
    </html>

    Actually, within the above code, the “meta” tag is not necessary.  Since I developed the above code using Visual Studio.NET 2003 Enterprise Architect, it was automatically added to provide its full-featured mechanisms. 

    The explanation for the above code is given in the next section.

    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

    - 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
    - Maximizing and Restoring HTML Images with th...
    - Maximizing and Restoring HTML Images with th...
    - Handling Hyperlinks and Images in HTML







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