473,698 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OnMouseOver does not change color

93 New Member
Hi

Why the code below does not change the color. I can only see the pointer change only but it does not change the color?

Please help and Thnaks

nma

[HTML]<td width="100" height="17"><a href="some.html " onmouseover="do cument.t6.src=I mage3.src;" onmouseout="doc ument.t6.src=Im age2.src;"><img name="t6" src="Highlight. jpg" width="100" height="17" border="0"></a></td>[/HTML]

on the declaration...
<SCRIPT LANGUAGE="JavaS cript">

Image1 = new Image
Image2 = new Image
Image3 = new Image

Image1.src="non Highlight.jpg";
Image2.src="Hig hlight.jpg";
Image3.src="Hig hlight-red.jpg";
</script>
Jan 16 '08 #1
5 1915
acoder
16,027 Recognized Expert Moderator MVP
Change the new image declarations to 'new Image();'.

Use the document.images array:
[html]<td width="100" height="17"><a href="some.html " onmouseover="do cument.images['t6'].src=Image3.src ;" onmouseout="doc ument.images['t6'].src=Image2.src ;"><img name="t6" src="Highlight. jpg" width="100" height="17" border="0"></a></td>[/html]
Jan 16 '08 #2
nma
93 New Member
Hi Again,

I try the code but it change the color at wrong cell. When at cell t2 is mouseover but then cell t2 at second row change the color. Why it is happens?


Declaration..

Image1 = new Image();
Image2 = new Image();

Image1.src="Hig hlight.jpg";
Image2.src="Hig hlight-red.jpg";


Expand|Select|Wrap|Line Numbers
  1. <tr cellspacing="0" border="0" cellpadding="0">
  2. <td align="right" class="timelinebar_text">Exciting</td>    
  3. <td width="10" height="17" ><img name="t1" src="nonHighlight.jpg" width="10" height="17" border="0"></td>
  4. <td width="20" height="17"><a href="some.html" onmouseover="document.images['t2'].src=Image2.src;" onmouseout="document.images['t2'].src=Image1.src;"><img name="t2" src="Highlight.jpg" width="100" height="17" border="0"></a></td>
  5.  
  6. .......
  7.  
  8. </tr>
  9. <tr cellspacing="0" border="0" cellpadding="0">
  10. <td  align="right" class="timelinebar_text">Montage</td>    
  11. <td width="10" height="17"><img name="t1" src="nonHighlight.jpg" width="10" height="17" border="0"></td>
  12. <td width="100" height="17"><img name="t2" src="nonHighlight.jpg" width="100" height="17" border="0"></td>
  13. .......
  14.  
Jan 17 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
Hi Again,

I try the code but it change the color at wrong cell. When at cell t2 is mouseover but then cell t2 at second row change the color. Why it is happens?
Because you've given them the same name, so it uses the second image with name t2. Give each image a unique name, or if not, give them a unique id and then access them using document.getEle mentById(imageI D) instead.
Jan 18 '08 #4
nma
93 New Member
Because you've given them the same name, so it uses the second image with name t2. Give each image a unique name, or if not, give them a unique id and then access them using document.getEle mentById(imageI D) instead.

Thank you so much :)

nma
Jan 18 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
You're welcome. Glad it helped.
Jan 18 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
17107
by: Tim | last post by:
Hope someone in the big wide world can help... What I want to do is have an image slideshow which automatically scrolls through a series of images very fast, then pauses when you move your mouse over the image. The images will flick through (at a rate of about 5 per second) then pause when the user onMouseOver's. Any help would be gratefully received. :o)
7
2274
by: Richard | last post by:
I know I can have like <a href="#" onclick="dothis" onmouseover="dothat"> But how do you properly code two mouseover's in one statement? <a href="#" onmousever="dothis" onmouseover="dothat"> As an example of use: Column A holds menu items. When a mouse over is performed, two actions take place instead of one. Action one sends an image to a division in column B, action two sends text to another division in column B.
12
12277
by: Epetruk | last post by:
Hi all, I want a page where the contents of a table cell are replaced with an image when the mouse moves over the cell, and the text is restored when the mouse moves out. Here's the html for the page: <HTML> <HEAD> <style type="text/css">
5
3508
by: Martin Chen | last post by:
I have a frame set (as per MS FrontPage 2000). It has a contents and a main frame. The contents frame has a menu bar written with with javascript (in the context of a table). In IE6.1 everything works fine as it also does in firefox if I call the contents frame directly (i.e. outside of its frameset). However, if I call my main page (index.html) which invokes the frame set, the contents frame javascript menubar onmouseover function...
3
3945
by: drjackk | last post by:
Hello, I'm trying to change the onmouseover event dynamically. This sets-up the initial onmouseover event: <a href="home.html"> <img border="0" id="img22" src="images/home1.jpg" height="15" width="85" alt="Home" onmouseover="FP_swapImg(1,0,/*id*/'img22',/*url*/'images/home2.jpg')"</a>
4
2132
by: Rob R. Ainscough | last post by:
I'm using .NET v1.1 with ASPX web page. I'm trying to have a RollOver hyperlink that will change images on an image control and update the text in a Label control. I've got the image swapping working, however I don't know how to get my Label control text to change with the onMouseOver event HTML... </asp:hyperlink><asp:hyperlink id="lnkImageS" style="Z-INDEX: 113; LEFT:
3
5871
by: Vear | last post by:
Hi, I'm looking to change the cssclass on a hyperlink with the onmouseover. I've tried the 3 syntax's below but to no success. Can someone point me in the right direction. Thanks HyperLink1.Attributes.Add("onmouseover", "this.ClassName='hover'") HyperLink1.Attributes.Add("onmouseover", "this.CssClass='hover'") HyperLink1.Attributes.Add("onmouseover", "this.Class='hover'")
3
6571
by: =?Utf-8?B?RGVlcGE=?= | last post by:
Hi All, I have a webform in asp.net framework 1.1 where the dropdownlist is populated with list of locations from the database. The depending on the list selected, the user will be able to see functions associated for that location. Ex: Location: Charleston Functions: Add, Delete, Cancel, Edit Location: Los Angeles
1
1852
by: Goutour | last post by:
Hello, I am a 2-day old Javascript developer :-) and I have a problem. I am trying to do examples I find on net about using onmouse events. I found a javascript that generates flying objects, and I wanted to be able when I point my mouse on any of them to replace it with another picture. It is pretty straight forward to do that in html coding as I found out these days, but when I tried to use a onmouseover event in the javascript that creates...
0
8604
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9160
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8862
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6521
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.