JustSlides is a simple Java applet that can be embedded in a web page to display a slide show. It is designed to do one job well – that is, to display a series of images, scaled smoothly to fit the available space. Here are its main features:
To just use the Java applet on your website, you need only this Java Archive file, which you should put somewhere where the page containing the slide show can reference it. Here is an example slide show:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>My Slide Show<title>
</head>
<body>
<applet code="JustSlides.class"
archive="../script/JustSlides.jar"
width="400" height="300">
<param name="autoadvance" value="yes">
<param name="time" value="5">
<param name="dir" value="slides">
<param name="1" value="pic1.jpg,Caption of first picture">
<param name="2" value="pic2.jpg,Caption of second picture">
<param name="3" value="pic3.jpg,Caption of third picture">
</applet>
</body>
</html>
As you can see, each slide should be on a separate line. The ‘name’ parameters must begin at 1 and be numbered consecutively. The ‘value’ parameter is the file name of the image, a comma, and the caption. The caption is optional. The other parmaters are as follows:
| name | value |
|---|---|
| autoadvance | Whether the slides begin playing automatically (yes or no) |
| time | The time between slides when they are playing (in seconds) |
| dir | Optional parameter to specify a path to the images |
To display the slides in a full-screen window requires a bit of JavaScript. This is how the slide shows on this web site are done. Here is an example of how to open a new window as near full-screen as possible in as many browsers as possible. (fullscreen=yes is not supported in many browsers, and Mozilla in particular uses the dimensions to set the window inner-size. This makes it impossible to create a window that is exactly full-screen, since the dimensions of the window decorations can vary depending on window manager and user preferences.) Note that the following should be entered on a single line:
<a href="slideshow.html"
onclick="window.open('slideshow.html', null, 'fullscreen=yes, width='
+ (screen.availWidth-100) + ',height=' + (screen.availHeight-100));
return false">Slide show</a>
Then in the slide show page itself, you need to use JavaScript to size the applet to the window, because <applet width="100%" height="100%" ...> just doesn’t work in most browsers (sigh). This is what I use:
<head>... usual head elements...<script language="JavaScript"><!-- function getSize() { var myWidth = 0, myHeight = 0; if (typeof(window.innerWidth) == 'number') { // Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else { if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { // IE 6+ in 'standards compliant mode' myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight; } else { if (document.body && (document.body.clientWidth || document.body.clientHeight)) { // IE 4 compatible myWidth = document.body.clientWidth; myHeight = document.body.clientHeight; } } } return [myWidth, myHeight]; } --></script> </head> <body> <a href="#" onclick="window.close();">Close this window</a> <script language="JavaScript"><!-- var d = getSize(); document.writeln('<applet code="JustSlides.class" archive="../script/JustSlides.jar" width="' + (d[0]-8) + '" height="' + (d[1]-23) + '">'); //--></script> <param name="autoadvance" value="yes">etc...
getSize() is just a function that attempts to get the inner window size regardless of the browser being used.
Unfortuantely, as with sizing the window I have to leave an arbitrary amount of spare space. In this case, I’ve allowed 8 pixels spare on the width and 23 in the height to allow for browser discrepancies over whether the status bar is included etc.
The source code is here. It is released under the following BSD-style license.
Copyright (c) 2003, Ian Goldby
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.