JavaScript
  Home arrow JavaScript arrow Page 4 - Working with Pop Ups and Browser Windows i...
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 
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? 
JAVASCRIPT

Working with Pop Ups and Browser Windows in JavaScript
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 8
    2006-04-25

    Table of Contents:
  • Working with Pop Ups and Browser Windows in JavaScript
  • How to write to a pop up window dynamically using JavaScript
  • How to access the data available in a pop up window from within the main window using JavaScript
  • How to access the data available in the main window from within a pop up window and vice versa using JavaScript
  • How to access the data available in main window from within a popup window and vice-versa using JavaScript: discussion

  • 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


    Working with Pop Ups and Browser Windows in JavaScript - How to access the data available in the main window from within a pop up window and vice versa using JavaScript


    (Page 4 of 5 )

    The code for the main window would be as follows:

    <html>
          <head>
                <meta  name=vs_targetSchema
     content="http://schemas.microsoft.com/intellisense/ie5">
    <script  id="clientEventHandlersJS"  language="javascript">
    <!--
    // global variable for subwindow reference
    var w;
    function openNewWindow( ) {
          if (!w || w.closed) {
            w = window.open("","NewWindow","status,height=200,width=300");
            // delay writing until window exists in IE/Windows
            setTimeout("openNewWindow( )", 50);
        } else if (w.focus) {
            // window is already open and focusable, so bring it to the front
            w.focus( );
        }
        // write HTML to new window document
        w.location.href="HTMLPage7_1.htm";
        w.document.close( ); // close layout stream
    }

    function Button1_onclick() {
          openNewWindow();
    }

    function Button2_onclick() {
          document.all.txtParentName.value = w.document.getElementById
    ("txtName").value;
    }

    //-->
                </script>
          </head>
          <body>
                <form  id="form1">
                      Enter Name:<input  id="txtParentName"  type=text>
                      <input  type="button"  value="Show"  id="Button1"
     name="Button1"  onclick="return Button1_onclick()">
                      <input  type="button"  value="Get"  id="Button2"
     name="Button2"  onclick="return Button2_onclick()">
                </form>
          </body>
    </html>

    The code for the web page (HTMLPage7_1.htm) for the pop up window would be as follows:

    <!DOCTYPE  HTML  PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title></title>
    <meta  name="GENERATOR"  content="Microsoft Visual Studio .NET 7.1">
    <meta  name="vs_targetSchema"
     
    content="http://schemas.microsoft.com/intellisense/ie5">
    <script  id="clientEventHandlersJS"  language="javascript">
    <!--
    function Button1_onclick() {
          document.all.txtName.value = opener.document.forms
    ["form1"].txtParentName.value;
    }
    function Button2_onclick() {
          opener.document.forms["form1"].txtParentName.value =
    document.all.txtName.value;
    }

    //-->
                </script>
    </head>
    <body>
    Enter Name:<input  id="txtName"  type=text  NAME="txtName">
    <input  type="button"  value="Show"  id="Button1"  name="Button1"
     onclick="return Button1_onclick()">
    <input  type="button"  value="Show at parent"  id="Button2"
     name="Button2" onclick="return Button2_onclick()">
    </body>
    </html>

    You can find the explanation for the above code in the next section.

    More JavaScript Articles
    More By Jagadish Chaterjee


       · The example scripts are only supported by Internet Explorer since he uses...
       · Hai, get in touch with popups and browser windows using basic JavaScripts.
     

    JAVASCRIPT ARTICLES

    - More on JavaScript Array Objects
    - Methods of the DOM Location Object
    - The DOM Location Object Properties
    - Handling Remote Files with JavaScript Click ...
    - Using Click Interceptions with a Database-Dr...
    - Using JavaScript Click Interceptions in an I...
    - Using Click Interceptions with JavaScript
    - QuickSort in Action
    - Quicksort
    - Using Mod_Security to Protect Your Server
    - Detecting and Countering Server Intrusions
    - Securing Your Web Server
    - Building a Secure Web Server
    - Protecting the Server
    - Book Review: Learning the Yahoo! User Interf...


     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     





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