Microon JS Random Image Component 1.2 ©2002 Microon.Net
Description
Microon JS Random Image Component inserts one random chosen image (from the specified folder) into a web page.
It is very similar to Microon ASP Random Image Component, with some advantages and some disadvantages in comparison to it.
Features
- Only 2 code lines to be inserted into the web page
- It is not necessary to specify a predefined list of images
- Automatic image adaptation to its dimension
- Images can be linked to a specified page, or can be linked to the same image (in full size)
- Images can be forced to any width, any height, or to both
- It is possible to disable the right-click menu on the image (useful for copyright purposes)
- It is possible to disable the IE 6 image toolbar (useful for copyright purposes)
Advantages
The main advantage of JS (jscript) version of Microon Random Image Component is that it can be used on every web site and on every type of web page, because it is executed locally on the client machine.Disadvantages
For the same motives mentioned above, this JS version, since it is executed on client machine, can't automatically scan the images on the server folder specified. So it is necessary to rename the images with a sequential name (such as image1.jpg, image2.jpg, image3.jpg, etc.); it is also necessary to specify the max number of images (for ex. if the last image is image44.jpg, you must specify 44), and the image extension (gif or jpg) (so it is not possible to have mixed extension gallery). If your web site supports ASP, it is highly recommended to use the ASP version of Microon Random Image Component.
Syntax
<script>
MicroonRandomImage(path, prefix, numImages, imgType, link, width, height, debugMode, NoMenu, NoGallery);
</script>The MicroonRandomImage component syntax has these parts:
Part Description path Relative path to the folder containing the images. prefix String specifying the fixed part in the name of the image (EX. if your images are named myImage1.jpg, myImage2.jpg, myImage3.jpg, ...., myImage32.jpg, then prefix must be "myImage") numImages Number that specifies the last image (EX. if your images are myImage1.jpg, myImage2.jpg, myImage3.jpg, ...., myImage32.jpg, then numImages must be 32. imgType String specifying images exentension ("jpg" or "gif") link String used to specify the link on the image. Values:
- "" (empty string): no link is added to the image;
- "===": link to the picked image (Ex: image.jpg) in full size;
- To link to an external page, for example myPage.asp, simply write "myPage.htm".
width Number specifying the width, in pixel, to be forced for images. If you don't want to force images width, this parameter must be an empty string, that is "". height Number specifying the height, in pixel, to be forced for images. If you don't want to force images height, this parameter must be an empty string, that is "". debugMode If equal to 1, some debug messages are displayed, besides the image. NoMenu If equal to 1, the right-click contextual menu on the image is disabled. NoGallery If equal to 1, the IE 6 image toolbar is disabled. In the hosting page must be inserted, before component call, the line:
<script language="jscript.encode" src="path to file RandomImage.js"></script>(These lines do not affect the rest of the web page)
Example: if the file RandomImage.js is located in the same folder of the calling web page, the code must be:
<script language="jscript.encode" src="RandomImage.js"></script>
Remarks
Images to be used with Microon Random Image Component must be named with a sequential name;
for example if you have 7 images, they can be named:
myImage1.jpg, myImage2.jpg, myImage3.jpg, myImage4.jpg, myImage5.jpg, myImage6.jpg, myImage7.jpg
(the first has index 1 and the last has the index 7).
So in the component call, prefix="myImage" ... numImages=7 ... imgType="jpg"Examples
Example1: test1.htm
<html>
<head>
<title>Random Image</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="jscript.encode" src="RandomImage.js"></script>
</head><body bgcolor="#FFFFFF" text="#000000">
<script>
MicroonRandomImage("../images","ciao",9,"jpg","link.htm",320,450,0,1,1);
</script></body>
</html>--> This page inserts an image taken from the folder called images, that is located one level up the folder of the test1.htm calling file, with a link to the page link.htm;
images are named ciao1.jpg, ciao2.jpg, ciao3.jpg, ..., ciao9.jpg;
the picked image will be forced to 320 pixels in width and 450 pixels in height.
Debug messages are not displayed, the right-click contextual menu on the image is disabled, IE 6 image toolbar is disabled.
The file RandomImage.js is located in the same folder of the calling file test1.htm.For other examples, see the Microon ASP Random Image Component readme file.