JavaScript
  Home arrow JavaScript arrow Page 3 - Using Multiple Containers to Build Pop Up ...
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

Using Multiple Containers to Build Pop Up DIVs with the DOM and AJAX
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2007-02-07

    Table of Contents:
  • Using Multiple Containers to Build Pop Up DIVs with the DOM and AJAX
  • Going backwards: the original pop-up generating script
  • Working with multiple pop-up DIVs
  • Listing the improved version of the pop-up generating application

  • 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


    Using Multiple Containers to Build Pop Up DIVs with the DOM and AJAX - Working with multiple pop-up DIVs


    (Page 3 of 4 )

    As I stated in the beginning of this article, the primary goal here is to improve the original application in such a way that it can work with many pop-up DIVs in the same web page, and certainly not just one.

    Therefore, I'll simply define a new JavaScript function that will check to see whether a specific web page element has the value "popupcontainer " for its class attribute. If this condition is true, the appropriate event handlers will be attached to the aforementioned element, in this way "activating" a new pop-up box for that container.

    Does this sound a bit confusing? It shouldn't. Now, to clarify any eventual doubts, please examine the signature for this brand new function, which has been named "activatePopupDivs()". It looks like this:

    // activate pop-up DIV elements
    function activatePopupDivs(){
       var divs=document.getElementsByTagName('div');
       if(!divs){return};
       for(var i=0;i<divs.length;i++){
         if(divs[i].className=='popupcontainer'){
           // display pop-up DIV element
           divs[i].onmousemove=displayPopupDiv;
           // hide pop-up DIV element
           divs[i].onmouseout=hidePopupDiv;
         }
       }
    }

    As you can see, the definition for the above function is indeed short and straightforward. The referenced function simply loops over all the DIVs included in the corresponding web document and verifies whether these elements have a value of "popupcontainer" for their class attribute. In that case, the pair of "displayPopUpDiv()" and "hidePopUpDiv()"  functions that were shown in the first article are tied to the element in question, which implies that after running the previous function, multiple pop-up DIVs can be included into the same web page. Pretty good, right?

    Also, you should notice that the "activatePopupDivs()" function traverses all the DIVs contained in the web document, which can sometimes be an unnecessary and time-consuming process. Nevertheless, this condition can be easily modified to loop over all the elements that belong only to a specific area within the respective web page.

    Okay, now that you hopefully learned how to create a short JavaScript function that provides the overall application with the capacity for using multiple pop-up DIVs, it's time to leap forward and see how the complete script looks after incorporating the new function that I explained before. Besides, I'll introduce a small change to the original "displayPopUpDiv()" function to fix the browser compatibility issue related to Internet Explorer that I mentioned in the introduction of this tutorial.

    To see how all of these improvements will be incorporated into the original pop-up generating application, click on the link below and read the following section.

    More JavaScript Articles
    More By Alejandro Gervasio


       · This second part of the series shows how to build multiple pop-up DIVS, and it...
     

    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 6 hosted by Hostway
    Stay green...Green IT