473,466 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Javascript Mouseover Problem

For some reason when I add additional buttons a 3rd button and beyond
i cant get the effect to work and I get errors...I cant understand
why...

<SCRIPT LANGUAGE = "javascript"><!--

if (document.images) { // Active Images
img1on = new Image();
img1on.src = "button1_on.jpg";

img2on = new Image();
img2on.src = "button2_on.jpg";

img1off = new Image();
img1off.src = "button1_off.jpg";

img2off = new Image();
img2off.src = "button2_off.jpg"; }

// Function to 'activate' images.
function imgOn(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "on.src");
}
}

// Function to 'deactivate' images.
function imgOff(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "off.src");
}
}

// -->
</SCRIPT>
<A HREF="page1.htm" onMouseOver="imgOn('img1')"
onMouseOut="imgOff('img1')">
<IMG NAME="img1" SRC="button1_off.jpg" ALT="mouseover button"
HEIGHT="30"
WIDTH="147" VSPACE="0" HSPACE="0" BORDER="0"></A>

<A HREF="page2.htm" onMouseOver="imgOn('img2')"
onMouseOut="imgOff('img2')">
<IMG NAME="img2" SRC="button2_off.jpg" ALT="another mouseover button"
HEIGHT="30"
WIDTH="147" VSPACE="0" HSPACE="0" BORDER="0"></A>
Jul 23 '05 #1
3 1752
Lee
richk said:

For some reason when I add additional buttons a 3rd button and beyond
i cant get the effect to work and I get errors...I cant understand
why...


The code you posted only has 2 buttons (and there is
at least one typo). Post the code that you want to
work, but doesn't.

Jul 23 '05 #2

I try with a third button and I don't see any problem
I use the following code and it seems to work

<html><head></head><body>
<SCRIPT LANGUAGE = "javascript"><!--

if (document.images) { // Active Images
img1on = new Image();
img1on.src = "button1_on.jpg";

img2on = new Image();
img2on.src = "button2_on.jpg";

img3on = new Image();
img3on.src = "button3_on.jpg";

img1off = new Image();
img1off.src = "button1_off.jpg";

img2off = new Image();
img2off.src = "button2_off.jpg";

img3off = new Image();
img3off.src = "button3_off.jpg";

}

// Function to 'activate' images.
function imgOn(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "on.src");
}
}

// Function to 'deactivate' images.
function imgOff(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "off.src");
}
}

// -->
</SCRIPT>
<A HREF="page1.htm" onMouseOver="imgOn('img1')"
onMouseOut="imgOff('img1')">
<IMG NAME="img1" SRC="button1_off.jpg" ALT="mouseover button"
HEIGHT="30"
WIDTH="147" VSPACE="0" HSPACE="0" BORDER="0"></A>
<br>
<A HREF="page2.htm" onMouseOver="imgOn('img2')"
onMouseOut="imgOff('img2')">
<IMG NAME="img2" SRC="button2_off.jpg" ALT="second mouseover button"
HEIGHT="30"
WIDTH="147" VSPACE="0" HSPACE="0" BORDER="0"></A>
<br>
<A HREF="page3.htm" onMouseOver="imgOn('img3')"
onMouseOut="imgOff('img3')">
<IMG NAME="img3" SRC="button3_off.jpg" ALT="third mouseover button"
HEIGHT="30"
WIDTH="147" VSPACE="0" HSPACE="0" BORDER="0"></A>
</body></html>
--
Ce message a ete poste via la plateforme Web club-Internet.fr
This message has been posted by the Web platform club-Internet.fr

http://forums.club-internet.fr/
Jul 23 '05 #3
Dominique wrote:
[The usual eval() nonsense testing for the wrong property]


See
<http://jibbering.com/faq/#FAQ4_40>
<http://pointedears.de/scripts/test/whatami>
and last but not least
<http://pointedears.de/scripts/test/hoverMe/>

hoverMe is for free and free software,
only take heed of the GPLv2 or above.
HTH

PointedEars
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
3
by: John Ortt | last post by:
I appologise for reposting this but I have been trying to find a solution all week with no avail and I was hoping a repost might help somebody more knowledgable than myself to spot the message... ...
3
by: jimmygoogle | last post by:
I posted earlier with a scope problem. I think I resolved it in IE but in Firefox it still exists. Anyone have any ideas/experience with this? I attached my code sorry it is so long. You can...
1
by: Ernst Lindner | last post by:
Hello, hopefully somebody can help me. In my homepage I would like to install a picture gallery (small pictures). If the user places the mouse over a picture, by using the event handler...
2
by: sgMuser | last post by:
Hi, I am not a good developer of Javascript codes. Needs this help to make some modification to this famous free javascript from Anarchos. i am using this in one of my webpage. What it does is,...
4
by: Tassie | last post by:
I have put javascript menus on some of the navigation buttons on my website - they are supposed to load on mouseover. Before I uploaded the site, they appeared to work. On all of the navigation...
2
by: OmniX | last post by:
Hi Guys, the problem im having is constructing a function that is usable for any submit button if it meets a certain criteria (this case mouseOver). Now orginally I was using the submit button for...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.