Important alert: (current site time 7/16/2013 6:57:17 AM EDT)
 

VB icon

ColdFusion 5 Image Output Functions (UDF)

Email
Submitted on: 5/6/2001 5:40:33 PM
By: Rabid Nerd Productions  
Level: Intermediate
User Rating: By 1 Users
Compatibility: Cold Fusion 4.5
Views: 11687
author picture
(About the author)
 
     These custom CF 5 functions can be included in your application.cfm for universal use, or in each file as needed. The "RollOver" function takes 3-4 parameters and returns the HTML to produce rollover images with or without a link. The "PreloadImg" takes any number of variables and preloads the images in the visitor's browser using JavaScript. You typically pass rollover image URLs to prevent the delay associated with the first mouseover otherwise experienced.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
// for :ColdFusion 5 Image Output Functions (UDF)
//**************************************
(c)2001 Herb Riede This code may not be submitted to another free code resource without written permission of Herbert L. Riede.
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: ColdFusion 5 Image Output Functions (UDF)
// Description:These custom CF 5 functions can be included in your application.cfm for universal use, or in each file as needed.
The "RollOver" function takes 3-4 parameters and returns the HTML to produce rollover images with or without a link.
The "PreloadImg" takes any number of variables and preloads the images in the visitor's browser using JavaScript. You typically pass rollover image URLs to prevent the delay associated with the first mouseover otherwise experienced.
// By: Rabid Nerd Productions
//
// Inputs:RollOver( name, img, imgover [, linkurl])
name - The name to give to the image for use by JavaScript/VBScript to access it's properties client-side. Must be page-unique.
img - URL to the normal image. May be relative or absolute.
imgover - URL to the "rollover" or "mouseover" image. May be relative or absolute.
linkurl (optional) - If exists, clicking the image will go to this URL. Otherwise, clicking image does nothing.
----------------------------
PreloadImg([imgurl, imgurl, imgurl, ...])
Calling this function will preload your mouseover/rollover images (the ones provided as "imgover" in RollOver() function calls)
You must call this in your <HEAD> tag and add onload="PreloadImg();" in your <BODY> tag for it to function correctly.
All image URLs may be relative or absolute
//
// Returns:RollOver returns the HTML to create a rollover effect when you place your mouse over the image
PreloadImg returns the JavaScript (including surrounding <script> tags) to preload mouseover images to prevent the delay associated with the first mouseover.
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=8&lngWId=9//for details.//**************************************

function RollOver( name, img, imgover) {
HTMLOut = "<a href='";
if (ArrayLen(Arguments) eq 4) {
 HTMLOut = "#HTMLOut##Arguments[4]#'";
} else {
 HTMLOut = "#HTMLOut####name#' name='#name#'";
}
HTMLOut = "#HTMLOut# onmouseover='#name#.src = ""#imgover#"";' onmouseout='#name#.src = ""#img#"";'><img src='#img#' name='#name#' border=0></a>";
 return HTMLOut;
}
function PreloadImg() {
HTMLOut = '<script language="JavaScript"> PreloadImgFlag = false;
function AddImg(newimg) {
 if (document.images) {
addimage = new Image();
addimage.src = newimg;
return addimage;
 }
}
function PreloadImg() {
 if (document.images) {';
for (imgnum = 1; imgnum lte ArrayLen(Arguments); imgnum=imgnum+1) {
 HTMLOut = '#HTMLOut#
 ploadimg#imgnum# = AddImg("#Arguments[imgnum]#");';
}
HTMLOut = '#HTMLOut#
 }
PreloadImgFlag = true;
} 
</script>';
return HTMLOut;
}


Other 4 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.