473,320 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Onmouseover event

6
Hi all

I just started developing a website and are really new to this so please be patient.

I have a table 3 columns 9 rows. I use row 1,4 and 7 as table headers -2,5 and 8 as images and 3,6 and 9 as description fields.

I want to be able to have a onmousover and onmouseout function on the images within the table.

I have tried various javascripts and can not get it to work. Is it correct to have the javascript in the head section and then have the onmouseover and onmouseout functions within the table data.

I am develloping it on my local drive. Does this have any impact on the javascript?

The code I have is the following for the script:
<script type="text/javascript">
function mouseOver()
{
document.yhol.src ="krabi1.jpg"
}
function mouseOut()
{
document.yhol.src ="yumtiholidays.jpg"
}
</script>

I then have the following in the specific tabledata where the first image is:

<td align="center"><a href="yumtiholidays.html" onmouseover="mouseOver()" onmouseout="mouseOut()"> <img src="yumtiholidays.jpg" name="yhol" alt="Maldives" width="300" height="167" border="0" /></a></td>

Thanks
May 20 '07 #1
1 1414
pbmods
5,821 Expert 4TB
Heya, Ohann. Welcome to TSDN!

Expand|Select|Wrap|Line Numbers
  1. <td align="center">
  2.     <a href="yumtiholidays.html" onmouseover="mouseOver()" onmouseout="mouseOut()">
  3.         <img src="yumtiholidays.jpg" name="yhol" alt="Maldives" width="300" height="167" border="0" />
  4.     </a>
  5. </td>
If I understand what you're saying, you want to change the source of an image when you mouse over it. Is this correct?

Expand|Select|Wrap|Line Numbers
  1. <td align="center">
  2.     <a href="yumtiholidays.html">
  3.         <img src="yumtiholidays.jpg" name="yhol" alt="Maldives" width="300" height="167" border="0" onmouseover="swap(this, 'yumtiholidays_over.jpg');" onmouseout="swap(this, 'yumtiholidays.jpg');" />
  4.     </a>
  5. </td>
Expand|Select|Wrap|Line Numbers
  1. function swap(image, newSrc) {
  2.     image.src = newSrc;
  3. }
  4.  
I forget if this works in Internet Explorer.

(don't bother reminding me)

Anyway, when you mouse over one of the images, it invokes swap and passes a reference to itself as the first argument, and an image filename as the second argument. Swap takes the first argument (in this case, the image object), and changes the source to the second argument.
May 20 '07 #2

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

Similar topics

1
by: christian9997 | last post by:
Hi I was trying to create a page where a SubMenu would appear when the user moved the mouse over an item of a Menu (= Table Cell <TD>). Unfortunately there seems to be a problem; the onMouseOver...
12
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...
7
by: windandwaves | last post by:
Hi Gurus I am trying to make this rather complicated maps with an a huge number of mouseovers and the like. I want to set up a function that OnMouseDown swaps the OnMouseOver and OnMouseOut for...
3
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"...
2
by: MrCode2k | last post by:
Hello, Trying to do: I just want a table that I can scroll and that has fixed headers. Problem: I got it to work but when I added the onmouseover event it didn't work anymore....
7
by: MrCode2k | last post by:
Hello, Trying to do: I just want a table that I can scroll and that has fixed headers. Problem: I got it to work but when I added the onmouseover event it didn't work anymore....
2
by: Justin Rowe | last post by:
I'm attempting to design a site with alot of dynamic content and intractability, however I've hit a snag when it comes to the function of the onMouseOver and onMouseOut events. Using a bit of code...
5
by: Sabbaath | last post by:
First off, I've pretty much convinced myself that the issue is that there are onmouseover events inside the div that contains an onmouseover event on it... I wrote the message below first. This was...
4
by: bgold12 | last post by:
Hey, I have kind of a weird problem. I have a span that I'm intentionally overflowing a table cell (<td>), so that it stretches over the table cells to the right of the parent table cell. I want...
3
by: linuskamb | last post by:
It seems, at least as far as my tests show, that Safari does not fire onmouseover for select options. with the code below, I can get all the messages in Firefox, but none in Safari. If I attach a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.