JavaScript
  Home arrow JavaScript arrow Using Click Interceptions with JavaScript
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 Click Interceptions with JavaScript
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-11-05

    Table of Contents:
  • Using Click Interceptions with JavaScript
  • Building a web form for using click interceptions
  • Using click interceptions for submitting and validating a web form via Ajax
  • Full source code for the click interceptions demonstration

  • 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 Click Interceptions with JavaScript


    (Page 1 of 4 )

    Web pages with AJAX tricks load extra content when certain parts of the page are clicked without reloading the entire page. This improves the visitor's experience. Wouldn't you like to get that functionality for your web site? This four-part series shows you how to do it with a technique called "click interception."

    Introduction

    One of the most beautiful aspects of modern web design is the clear differentiation between the distinct parts or layers that comprise a web site. On one hand there's the structural markup that defines the structure of the different web documents of the site, while on the other hand, there are the CSS styles and JavaScript code that reside happily on separated files. What a wonderful scenario!

    Indeed, over the last few years, this model has proven to be an efficient approach when it comes to separating structure from visual presentation, and also when it comes to extending the behavior of a web application by means of unobtrusive JavaScript.

    Naturally, the use of unobtrusive JavaScript code is one of the main pillars for developing client-side applications that will degrade gracefully when scripting has been disabled on a browser, meaning that it's possible, for instance, to enrich (or expand) the behavior of a database-driven web application via client-side scripting without making the application itself depend entirely of JavaScript.

    This way of linking one or more JavaScript programs to the bare bones structure of a web document leads directly to the implementation of a helpful technique known as "click interception." Before you start asking yourself what it is, let me give you a simple example: suppose for a moment that you've built with plain (X)HTML a fancy navigation bar for your brand new web site, whose elements link to different web pages. So far, nothing too complicated, right?

    Now, say that instead of showing the contents of these web pages in different windows, you want to display them in a container of the same web document via Ajax. In this particular situation, you can assign an "onclick" event handler to each link of the navigation bar to handle each HTTP request without having to reload the whole web page. This means that you're actually "intercepting" each click (hence the method's name) and handling the requests in the way that you want.

    Plus, there's an additional advantage in using click interceptions within the context of the previous example. If scripting has been disabled on the browser for whatever reason, the navigation bar will still work. Simple and efficient!

    Now that you have a pretty clear idea of what a click interception is, it's time to move forward and back up these concepts with concrete examples. Having said that, in this article series, I'll be showing you how to implement click interceptions in different cases, so you can use them successfully as part of your own JavaScript applications.

    Let's begin now!

    More JavaScript Articles
    More By Alejandro Gervasio


       · Click interceptions are a handy technique used for building JavaScript applications...
       · What is the purpose/function of the initializeForm function?
       · Thanks for commenting on my article. As I explained in the article, the...
     

    JAVASCRIPT ARTICLES

    - Toggling CSS Properties with the GX JavaScri...
    - Cancel, Queue and Pause Animations with the ...
    - Producing Elastic Effects with the GX JavaSc...
    - Moving Divs Diagonally with the GX JavaScrip...
    - Moving Elements Vertically and Horizontally ...
    - Making Bouncing Effects in Parallel with the...
    - Creating Bouncing Effects with the GX JavaSc...
    - Manipulating Background Colors with the GX J...
    - The GX JS Animation Framework
    - Debug Ajax-Generated Tags in Firefox
    - Building a Page Controller with the jQuery Q...
    - Paginating Database Records with the jQuery ...
    - Paginating Images with the jQuery Quick Pagi...
    - Hiding the Page Counter with the jQuery Quic...
    - Introducing the Quick Pagination jQuery Plug...







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