Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...An excellent site which has quite possibly prevented me from having a mental/nervous breakdown..."

Geography

Where in the world do Tek-Tips members come from?

MouseOver effect with a single image

ITA (Programmer)
5 May 00 8:11
I am using a single image with an image map as a navbar. I am trying to change the single image to another image from the hot spot on the page. I am having trouble figuring out the code for a single image. I am familiar with multiple images and changing them, but I am stuck with the single image. below is my code
************************************************************

<MAP NAME="BAR">
    <AREA SHAPE=RECT COORDS="(2,110)(42,110)" HREF="link.html"  ONMOUSEOVER=active('b1') ONMOUSEOUT=inactive('b1')>
    <AREA SHAPE=RECT COORDS="(2,111)(42,213)" HREF="LINK2.HTML" >
    <AREA SHAPE=RECT COORDS="(2,214)(42,325)" HREF="LINK3.HTML" >
    <AREA SHAPE=RECT COORDS="(2,326)(42,446)" HREF="LINK4.HTML" >
    <AREA SHAPE=RECT COORDS="(2,447)(42,541)" HREF="LINK5.HTML" >
  </MAP>
  
   <SCRIPT LANGUAGE="JavaScript">
    <!--HIDE FROM NON JAVA BROWSERS

//THIS IS A FUNCTION THAT WILL CHANGE THE IMAGE OVER THE
if (document.images){
b1on = new Image(); b1on.src = "images/b1a.gif";
b2on = new Image(); b2on.src = "images/b2a.gif";
b3on = new Image(); b3on.src = "images/b3a.gif";
b4on = new Image(); b4on.src = "images/b4a.gif";
b5on = new Image(); b5on.src = "images/b5a.gif";
//
b1off = new Image(); b1off.src = "images/b.gif";
b2off = new Image(); b2off.src = "images/b.gif";
b3off = new Image(); b3off.src = "images/b.gif";
b4off = new Image(); b4off.src = "images/b.gif";
b5off = new Image(); b5off.src = "images/b.gif";
}

//These are the functions that will be called from the mouseover and mouseout
function active(imgName){
if (document.images){
imgOn = eval(imgName + "on.src");
document[imgName].src = imgOn;
}
}

function inactive(imgName){
if (document.images){
imgOff = eval(imgName + "off.src");
document[imgName].src = imgOff;
}
}

     //STOP HIDING-->
   </SCRIPT>
   
   


<script LANGUAGE=JAVASCRIPT>

<!--

function  _CF_checkgetquestion(_CF_this)

    {

    return true;

    }


//-->

</script>

</HEAD>
<BODY BGCOLOR="#FFFFFF">
  <DIV ALIGN=LEFT>
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
  <TR>
<TD WIDTH="150">
  <IMG VALIGN=BOTTOM SRC="images/sc_logo.gif" >
</TD>
<TD WIDTH="490">
  <IMG SRC="images/b.gif" VALIGN=TOP USEMAP="#BAR" BORDER=0 NAME=b1>
</TD>
  </TR>
</TABLE>
  </DIV>
</BODY>
</HTML>
theEclipse (Programmer)
5 May 00 23:05
you are using :

document[imgName].src = ....;

try using :

document.images[imgName].src = ....;

theEclipse
eclipse_web@hotmail.com
robacarp.webjump.com
**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.

ITA (Programmer)
8 May 00 19:14
The code that I have written works for changing the image to another image. The problem that I am having is that document[imgName] is the always the same image to start with. I will try to explain better, in the code above I am chaning the image B1 to another image then B2 too another image then so on so forth. What I am trying to find is a way to use the same image i.e. B1 every time and then change to the other images dependent upon which hot spot the mouse is over.

I hope that this makes more sense than my first question.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close