Web-standard solutions for a non-standard world
This page contains a picture slideshow that requires JavaScript to navigate. The following links display the slideshow information.
Welcome to the BarelyFitz JavaScript slideshow!
Use the slideshow controls for a tour of the slideshow features.
This is free, open-source software: you can redistribute it and/or modify it under the terms of the GNU General Public License. For more information refer to the License page.
The slideshow is supported by user donations.
Use the Slideshow Wizard to create a slideshow - just copy the pictures onto your own website, and paste our HTML into your web page.
You can also use the Auction Wizard to create slideshows for your eBay auction pages.
Each slide can have the following attributes: an image, a link, a description, a window target, window attributes, a custom duration, and a custom image transition.
You can also add custom information to each slide.
Each image in the slideshow can be a different size - the slideshow can scale the image to a specific width and/or height, or the slideshow can automatically change to the new image size.
You can set an image transition, such as a fade-in transition, for the entire slideshow, or set a custom transition for each slide.
Users can trigger the link for a slide by clicking the image or by clicking a separate link or button. The link can open a new browser window, and you can specify custom window attributes for each slide, such as width, height, scrollbars, etc. If the window is hidden behind other windows, it is automatically popped to the front.
Each slide can have an annotation, which is displayed directly on the page. The annotation can contain text or HTML, and you can use style sheets to control the text appearance.
Tools are provided to make the text accessible to search engines and browsers that do not support JavaScript.
You can add a variety of controls for the slideshow, and the controls can be links or buttons.
Some of the available controls are: next slide, previous slide, goto a slide, start the slideshow, pause the slideshow, etc.
The slideshow can automatically advance the slides. You can set the duration for all of the slides, or set a custom duration for each slide.
You can shuffle the slides to provide a random order.
You can create more than one slideshow on a page. The slideshows can even update at different rates.
The slideshow can use a cookie to save its current position, so if you leave the page and come back it will continue where it left off.
The slideshow can preload all of the images, or (for a large number of pictures) you can specify the number of images to preload. For automatically running slideshows, the slideshow will not advance until the next slide is loaded.
The slideshow is written in easy to use object-oriented code, and has been tested on the Internet Explorer, Mozilla, Netscape, and Opera browsers. Tools are also provided for making the slideshow accessible to older browsers, non-JavaScript browsers, and search engines.
Dowload the main JavaScript source code, and save it in a file slideshow.js on your web server. Then in the HTML file where you want to display the slideshow, add the following in the HEAD section:
<SCRIPT TYPE="text/javascript" SRC="slideshow.js"> </SCRIPT>
Notes:
<SCRIPT TYPE="text/javascript"> <!-- INSERT_HERE // --> </SCRIPT>
Also in the HEAD section of your HTML file, initialize the slideshow object, and add some slides. This example shows three ways to add a slide, so pick the most appropriate method.
<SCRIPT TYPE="text/javascript"> <!-- SLIDES = new slideshow("SLIDES"); s = new slide(); s.src = "pics/pic1.jpg"; s.link = "pics/pic1-lg.jpg"; s.text = "Open link in same window"; SLIDES.add_slide(s); s = new slide(); s.src = "pics/pic2.jpg"; s.link = "pics/pic2-lg.jpg"; s.text = "Open link in new window"; s.target = "_blank"; SLIDES.add_slide(s); s = new slide(); s.src = "pics/pic3.jpg"; s.link = "pics/pic3-lg.jpg"; s.text = "Open link in new window with attributes"; s.target = "_blank"; s.attr = "width=320,height=245"; SLIDES.add_slide(s); //--> </SCRIPT>
Your BODY element should contain the following:
<BODY onLoad="SLIDES.restore_position(); SLIDES.update();" onUnLoad="SLIDES.save_position()">
<BODY onLoad="SLIDES.update()">
Now in the BODY section of your HTML file, where you want to display the slideshow, add the IMG tag:
<A HREF="javascript:SLIDES.hotlink()"> <IMG NAME="SLIDESIMG" SRC="pics/pic1.jpg" WIDTH="150" HEIGHT="150" BORDER="0" ALT="slideshow image"> </A>
If you want to display text descriptions for the images in your slideshow, include a DIV section and give it a unique ID:
<DIV ID="SLIDESTEXT"> </DIV>
<SCRIPT type="text/javascript"> <!-- document.write("<UL>\n"); document.write(SLIDES.get_all_text("<li>", "\n")); document.write("<" + "/UL>"); //--> </SCRIPT>
If you want to include links or buttons to control the slideshow, you can use the following links:
SLIDES.next() SLIDES.previous() SLIDES.play() SLIDES.pause() SLIDES.hotlink()
For example:
<A href="javascript:SLIDES.next()">next</A>
or if you're within a form you can use buttons:
<INPUT TYPE=button VALUE="next" onClick="SLIDES.next()">
Finally, after the IMG tag, you must finish configuring the slideshow and optionally start it running:
<SCRIPT TYPE="text/javascript"> <!-- if (document.images) { SLIDES.set_image(document.images.SLIDESIMG); SLIDES.set_textid("SLIDESTEXT"); // optional SLIDES.update(); SLIDES.play(); //optional } //--> </SCRIPT>
If you want your slideshow images to display at full size, do not use any WIDTH or HEIGHT parameters with your IMG element. The browser increases or decreases the size of the image as necessary.
<IMG NAME="ss_img" SRC="myslide.jpg">
To make the browser automatically scale the image, just add the desired image dimensions to your IMG element:
<IMG NAME="ss_img" SRC="myslide.jpg" STYLE="width:320px;height:200px">
This scales each image to the same size, but if your images have different aspect ratios it might cause the images to be distorted.
Another option is to specify only one dimension:
<IMG NAME="ss_img" SRC="myslide.jpg" STYLE="width:320px">
Then every image will be 320px wide, and the height of the image will be scaled so that the image has no distortion. But this will make the other elements on your page move around each time the image changes size.
If you want the overall size of the image area to stay the same, put your image into a TABLE with a fixed size. Make the size of the table equal to or slightly larger than the largest scaled size of your images.
<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" STYLE="width:320px;height:300px;text-align:center;background:black;"> <TR> <TD VALIGN="center"> <IMG NAME="ss_img" SRC="myslide.jpg" STYLE="width:320px" ALT="Slideshow image"> </TD> </TR> </TABLE>
In the previous example, if the image height is scaled to less than 300px, black bars will appear above and below the image.
To add a fade-in transition to your slides, simply add the following attribute to your IMG element:
STYLE="filter:progid:DXImageTransform.Microsoft.Fade()"
You can also set a different transition for each slide:
myslide.img = new slide('pic1.jpg'); myslide.filter = 'progid:DXImageTransform.Microsoft.Pixelate()'; SLIDES.add_slide(myslide);
var fadein_opacity = 0.04; var fadein_img = SLIDES.image; function fadein(opacity) { if (typeof opacity != 'undefined') fadein_opacity = opacity; if (fadein_opacity < 0.99 && fadein_img && fadein_img.style && typeof fadein_img.style.MozOpacity != 'undefined') { fadein_opacity += .05; fadein_img.style.MozOpacity = fadein_opacity; setTimeout("fadein()", 50); } } SLIDES.post_update_hook = function() { fadein(0.04); }
The slideshow code consists of two objects:
myslide = new slide(); myslide.src = "pics/slideimage.jpg"; myslide.text = "This is an image.";
myslide = new slide( "pics/slideimage.jpg", "", "This is an image.");
<IMG SRC="myimg.jpg" NAME="myimg"> <SCRIPT TYPE="text/javascript"> if (document.images) { myslideshow.set_image(document.images.myimg); } </SCRIPT>
<FORM NAME="SLIDESFORM" ACTION="slideshow.html"> <TEXTAREA NAME="SLIDESTEXT" ROWS="4" COLS="40" READONLY STYLE="width:400px" WRAP="virtual"> This field displays text for the image slideshow. </TEXTAREA> </FORM> <SCRIPT TYPE="text/javascript"> myslideshow.set_textarea(document.SLIDESFORM.SLIDESTEXT); </SCRIPT>
<DIV ID="SLIDESTEXT"> This area displays text for the image slideshow. </DIV> <SCRIPT TYPE="text/javascript"> myslideshow.set_textid("SLIDESTEXT"); </SCRIPT>
SLIDESHOW.pre_update_hook = function() { alert("Changing to next slide: " + this.slides[ this.current ].src); } SLIDESHOW.post_update_hook = function() { alert("Done changing to slide: " + this.slides[ this.current ].src); }
© 2003 Patrick Fitzgerald, All Rights Reserved
© 2003 Patrick Fitzgerald
slideshow.js is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Please give me credit and link back to this page to ensure that search engines give this page a higher ranking. You can add the following HTML to a page on your web site (it doesn't have to appear on the same page as your slideshow, just a page that is indexed by Google):
<A HREF="http://slideshow.barelyfitz.com/">JavaScript Slideshow</A> provided by <A HREF="http://www.barelyfitz.com/">BarelyFitz Designs</A>
If you like this script donate a few bucks, make an Amazon.com purchase through my links, or buy me something from my wishlist.
Page: all 1 2 3 4 5 6