JavaScript
  Home arrow JavaScript arrow Page 2 - Create Your Own DHTML Slideshow With a Fad...
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

Create Your Own DHTML Slideshow With a Fading Effect
By: Martin Tsachev
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 34
    2002-12-14

    Table of Contents:
  • Create Your Own DHTML Slideshow With a Fading Effect
  • The Script
  • The Slideshow Script
  • The Slideshow Script (contd.)
  • Conclusion

  • 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


    Create Your Own DHTML Slideshow With a Fading Effect - The Script


    (Page 2 of 5 )

    The HTML

    <h1>My DHTML slideshow gallery</h1>
    <div align="center">
    <a href="javascript:changeSlide(-1)">Previous</a>&nbsp;&nbsp;&nbsp;
    <a href="javascript:changeSlide(1)">Next</a>&nbsp;&nbsp;&nbsp;
    <a href="javascript:setFade(false)">No fade</a>&nbsp;&nbsp;&nbsp;
    <a href="javascript:setFade(true)">Fade</a><br>
    </div>

    <div id="slide0" class="slide">
    <img src="slide0.jpg" alt="slide0" width="100" height="50">
    </div>
    <div id="slide1" class="slide">
    <img src="slide1.jpg" alt="slide1" width="100" height="50">
    </div>
    <div id="slide2" class="slide">
    <img src="slide2.jpg" alt="slide2" width="50" height="100">
    </div>
    <div id="slide3" class="slide">
    <img src="slide3.jpg" alt="slide3" width="100" height="50">
    </div>


    This code is simple, but it works. Of course you do not have to name your images slide0.jpg and so on.

    The Style Sheet

    <style type="text/css">
    .slide {
    position : absolute;
    visibility : hidden;
    top : 200px;
    left : 50px;
    }

    #slide0 {
    visibility : visible;
    }
    </style>


    Maybe you’re wondering why I didn't set the clipping in the style sheet? The answer is simple: Netscape Navigator 4 can only get the height/width of the block (actually the clipping area), when no clipping is set (apparently it doesn't get the height value properly, but I have never seen a difference of more than 10 pixels).


    Explanation
    Firstly, the controls are set using anchors:

    <div id="slide0" class="slide">
    <img src="images/slide0.jpg" alt="slide0" width="100"
    height="50" border="0"></div>


    This sets the first slide of your DHTML slideshow. The img should be wrapped in a div because NN 4 considers only div's and span's for layers. The case is that NN 4 can only set visibility/clipping of a layer. The class="slide" is for setting the position and visibility of all slides, and the id is to identify the slide that needs to be viewed.

    .slide {
    position : absolute;
    visibility : hidden;
    top : 200px;
    left : 50px;
    }

    #slide0 {
    visibility : visible;
    }


    Firstly, the class definition for all of the slides. It sets the position to absolute to get the impression that the next slides comes from below the previous one (so that the user doesn't have to scroll down the page to see the next slide).

    visibility : hidden

    ... prevents the browser from visualizing the slides on the screen, while still reserving the space needed to actually display them. We also set the top and left co-ordinates of the slides (px is short for pixels).

    More JavaScript Articles
    More By Martin Tsachev


     

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