Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Client Side Scripting
User Name:
Password:
 

Closed Thread
Thread Tools   Display Modes
  View First Unread
 
Old 06-25-2004, 04:48 AM
  #16
agent002
Resident Opera Guru
 
agent002's Avatar
 
Join Date: Feb 2003
Location: Suomi... SUOH-MIH
Posts: 6,454
iTrader: (0)
agent002 is on a distinguished road
How do I change the src of an image when moving the cursor over it?

Here is a simple code snippet for doing that:
Code:
<img src="off.gif" alt="Alternate text" border="0"
onmouseover="this.src='on.gif';" onmouseout="this.src='off.gif';">
If you want to do many image rollovers on a page, you may want to use a function that doesn't require you to specify the onmouseout image src. Add this to the page header:
Code:
<script type="text/javascript">
//<![CDATA[
var restore = new Array();
function imgOver(whichImage, newSrc){
    restore[whichImage] = whichImage.src;
    whichImage.src = newSrc;
}

function imgOut(whichImage){
    whichImage.src = restore[whichImage];
}
//]]>
</script>
You can then use this code for the rollovers:
Code:
<img src="off.gif" alt="Alternate text" border="0"
onmouseover="imgOver(this, 'on.gif');" onmouseout="imgOut(this);">
agent002 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it?
Old 06-27-2004, 10:27 AM
  #17
agent002
Resident Opera Guru
 
agent002's Avatar
 
Join Date: Feb 2003
Location: Suomi... SUOH-MIH
Posts: 6,454
iTrader: (0)
agent002 is on a distinguished road
How do I preload images?

You only need to copy this code snippet to the page header:
Code:
<script type="text/javascript">
//<![CDATA[
// Specify images to preload here:
var preload = new Array('image1.gif', 'image2.gif', 'image3.gif');

var loader = new Array();
for(var i = 0; i < preload.length; i++){
    loader[i] = new Image();
    loader[i].src = preload[i];
}
//]]>
</script>
and specify the images to preload in the "preload" array.
agent002 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it?
Old 11-28-2004, 10:28 PM
  #18
Jon Hanlon
Super Guru (Moderator)
 
Jon Hanlon's Avatar
 
Join Date: Jul 2001
Location: Sydney, Australia
Posts: 1,842
iTrader: (0)
Jon Hanlon will become famous soon enough
Customising the Scrollbar

n8thegreat has written some neat scripts to enhance your scrolling experience.
They can be found at n-son.com/scripts/jsScrolling/
__________________
Jon Hanlon
Jon Hanlon is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it?

Closed Thread
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 10:57 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.