JavaScript
  Home arrow JavaScript arrow Page 2 - Using JavaScript Click Interceptions in an...
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? 
JAVASCRIPT

Using JavaScript Click Interceptions in an Image Gallery
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2008-11-12

    Table of Contents:
  • Using JavaScript Click Interceptions in an Image Gallery
  • Building the basic structure of an image gallery
  • Using click interception to modify existing behavior
  • Listing the full source code of the improved image gallery

  • 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 JavaScript Click Interceptions in an Image Gallery - Building the basic structure of an image gallery


    (Page 2 of 4 )

    Before I get my hands dirty coding any practical example, let me explain briefly how I plan to build this sample image gallery, which will be improved later on by means of click interceptions. First, the gallery in question will be comprised of a list of regular HTML links, which, when clicked on, will display in a different window a predefined image associated with the text included in each link. Still with me?

    Then, once this basic image gallery has been constructed, I'm going to use a few click interceptions to change the default behavior of the aforementioned links, and consequently, show the images on the same web page, instead of using a distinct one.

    But, as I said before, this process will be performed later on. So pay close attention to the definition of the following (X)HTML file, which is responsible for building the pertinent list of image links: 

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <title>Example on building an image gallery using click interception</title>

    <style type="text/css">

    body{

    padding: 0;

    margin: 0;

    background: #fff;

    }

    h1{

    font: bold 18pt Arial, Helvetica, sans-serif;

    color: #000;

    }

    a:link,a:visited{

    font: normal 10pt Arial, Helvetica, sans-serif;

    color: #00f;

    }

    a:hover{

    color: #f90;

    }

    #linkcontainer{

    width: 300px;

    padding: 5px;

    background: #eee;

    }

    #imgcontainer{

    width: 300px;

    text-align: center;

    }

    </style>

    </head>

    <body>

    <h1>Example on building an image gallery using click interception</h1>

    <div id="linkcontainer">

    <ul>

    <li><a href="sampleimagea.gif" title="First sample image goes here">View first image</a></li>

    <li><a href="sampleimageb.gif" title="Second sample image goes here">View second image</a></li>

    <li><a href="sampleimagec.gif" title="Third sample image goes here">View third image</a></li>

    </ul>

    </div>

    <div id="imgcontainer"></div>

    </body>

    </html>


    As you can see, the above (X)HTML file is quite simple to grasp, since all that it does is display a list of three links, which, when clicked on, will show a specific image in a different window. In this case, the sample images that I'm going to use here are called "sampleimagea.gif", "sampleimageb.gif" and "sampleimagec.gif" respectively. If you're curious about how they look, you can take a look at them below:





    So far, everything looks good. If you test the previous (X)HTML file on your own browser, in conjunction with the three images shown above, then you'll end up seeing a list of descriptive links, which, when clicked, will display the associated image in a different window.

    But what if I want the images in question to be shown in the same web page? Here's where click interceptions come in. It's possible to develop a small JavaScript application that changes the default behavior of each link included in the previous image gallery to display all the images within a predefined container of the same web document.

    Sounds pretty interesting, doesn't it? However, to see how this process will be performed, you'll have to click on the link below and keep up reading.

    More JavaScript Articles
    More By Alejandro Gervasio


       · In this second chapter of the series, clicks interceptions are applied to extend...
     

    JAVASCRIPT ARTICLES

    - Comparing Fields and Customizing Error Messa...
    - Checking Numbers and File Extensions with jQ...
    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek