HTML
  Home arrow HTML arrow Page 3 - 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  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
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 / 40
    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 - Making DIV more dynamic to write into IFRAME


    (Page 3 of 5 )

    Now, let us try to develop a simple script (JavaScript) which extends the script shown in the previous sections. 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(val)
    {
          var tDiv = document.getElementById("dvSample");
            var FirstElement = tDiv.firstChild;
            var v = FirstElement.nodeValue;
            var val2 = v.replace(/\%message\%/g, val);
            var tFrame = document.getElementById("myFrame");
            var doc = tFrame.contentDocument;
            if (doc == undefined || doc == null)
                doc = tFrame.contentWindow.document;
            doc.open();
            doc.write(val2);
            doc.close();      

          document.all.myFrame.style.visibility="visible";
    }

    function Button1_onclick() {
    var v = document.all("txtHTML").value;
    Show(v);
    }
    //-->
                </script>
          </head>
    <body>
          <div  id="dvSample">
          <!--
            <html>
              <body>
                %message%
              </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">
                      Enter some HTML: <input  type=text  id="txtHTML"><input  type="button"  value="Show"  id="Button1"  name="Button1"  onclick="return Button1_onclick()">
                </form>
          </body>
    </html>

    Within the above code, I made a dynamic drive by giving the flexibility to the user to enter his own information, which can be carried as content to IFRAME. 

    The HTML (or any information) entered by the user gets accepted into the textbox and we transfer that information to the function “show.”  The DIV contains a suspicious word, “%message%”.  We use this word to replace the content entered within the textbox.  This is one of the very clever techniques used in writing content to IFRAME dynamically.

    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...
       · I tried this tutorial but it didn't work in firefox 3.0. what are the firefox work...
       · document.all.myFrame.style.visibility="visible"; doesn't work in firefox...
     

    HTML ARTICLES

    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers
    - Downloading Long HTML Pages with ACP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT