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 
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 / 36
    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

    - 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