As the title says i'd like to have a image (mocha1150.Gif) and when the mouse moves over them id like them to change to mocha5150ani.Gi f and when the mouse moves out id like to change it back to mocha1150.Gif
I already have the code written can someone please tell me whats wrong with it? -
<html>
-
<head>
-
<script type="text/javascript">
-
function moveover(imga,ida)
-
{
-
document.getElementById('ida').src="imga";
-
}
-
function moveout(imgb,idb)
-
{
-
document.getElementById('idb').src="imgb";
-
}
-
</script>
-
</head>
-
-
-
-
-
<div style="position:absolute;top:20px;left:20%" align="center"><font face="arial" id="title" size="20" >Welcome to Spencer's Test website</font></div>
-
<img src="top.GIF" width="100%" height="75px" />
-
<br>
-
-
-
-
<img id="aa" src="mocha1150.GIF"
-
onmouseover="moveover(mocha5150ani.GIF,aa)"
-
onmouseout="moveout(mocha1150.GIF,aa)" />
-
-
-
<html>
-
-
also if theirs a way to do it without creating a function and doing it within the element can someone please tell me how?
4 5969 Dormilich 8,658
Recognized Expert Moderator Expert
first, function make coding easier. no need to drop them.
second, in JavaScript variables are not quoted. i.e. in your functions you define 2 parameters, but you don’t use them. in contrast to that, strings must always be quoted.
third, you have 2 functions doing exactly the same …
fourth, (advanced) you don’t need the document.getEle mentById() call. using the keyword for the current element is cleaner and shorter. - function changeSource(pic, obj)
-
{
-
obj.src = pic;
-
}
- <img src="mocha1150.GIF" onmouseover="changeSource('mocha5150ani.GIF', this)" onmouseout="changeSource('mocha1150.GIF', this)" />
PS. even that can be simplified, but that’s for later.
0k I updated my code, but it still does'nt work it displays the mouseout image only -
<html>
-
<head>
-
<script type="text/javascript">
-
function change(img,id)
-
{
-
id.src = img;
-
}
-
-
</script>
-
</head>
-
-
<div style="position:absolute;top:20px;left:20%" align="center"><font face="arial" id="title" size="20" >Welcome to Spencer's Test website</font></div>
-
<img src="top.GIF" width="100%" height="75px" />
-
<br>
-
-
<img src="mocha1150.GIF"
-
onmouseover="change(mocha5150ani.GIF,this)"
-
onmouseout="change(mocha1150.GIF,this)" />
-
-
<img src="mocha2150.GIF"
-
onmouseover="change(mocha5150ani.GIF,this)"
-
onmouseout="change(mocha2150.GIF,this)" />
-
-
<img src="mocha3150.GIF"
-
onmouseover="change(mocha5150ani.GIF,this)"
-
onmouseout="change(mocha3150.GIF,this)" />
-
-
<img src="mocha4150.GIF"
-
onmouseover="change(mocha5150ani.GIF,this)"
-
onmouseout="change(mocha4150.GIF,this)" />
-
<html>
-
Is there a reason why you are using javascript to do this when CSS can far easier?
using css :: - #div
-
{
-
background:orange;
-
}
-
#div:hover
-
{
-
background:url('images/img1.jpg');
-
}
Bharat Parmar(Bharat38 3)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Daniel |
last post by:
how to change the value of Request.ServerVariables on the
ser ver? if not possible is there some way to change it by sending back
javascript to the client and having the client automaticaly do something to
change the value of Request.ServerVariables I would like to
reset the value in Request.ServerVariables
|
by: Sakharam Phapale |
last post by:
Hi All,
How to capture Mouse Single click and mouse double click event on Commnad
Button.
I am doing as follows.
Private void Button1_MouseUp(Object sender,
System.Windows.Forms.MouseEventArgs e)
{
|
by: cyshao |
last post by:
I opened an image and want to change its size, then display it in a
ImageBox.
How can I do that ?
Thanks
Charles Shao
|
by: guoqi zheng |
last post by:
In a regular html form, when user press "enter" key, the form will be
submitted.
However, in ASP.NET web form, a form will only be submitted (post back) when
a special button is clicked. Many user get used to click "enter" key to
submit a form. How can I use "enter" key to submit/postback in ASP.NET.
Thank,
Guoqi Zheng
|
by: Mr Newbie |
last post by:
OK, I have a fairly simple setup where I have an Index of records which are
displayed using a datagrid on a page. When you click the link associated
with a Row (ArticleID) , this ID is passed to a page which creates an new
Article or Retreive an existing one depending if there is an ArticleID
passed to it.
So on my index page the user will be directed to the article page and will
either pick up an existing one or have a new one created....
| |
by: ramkishor |
last post by:
How can I change the color of button on mouse move over it.
help .
|
by: Marc |
last post by:
Anyone know how to add a drop down menu to a button that will appear
when you right click the mouse?
|
by: williamr4j |
last post by:
Very first thing, after preloader, is a blurry image that is supposed to get clear when mouse goes over the image. Problem is, the image that is clear will not, when previewing the movie, move from the top left corner. It is supposed to be right on top of the other image, which is in the middle of the screen. when i go into the layer that the clear image is it is right over the blurry image. I don't understand why, and have tried many different...
|
by: mykeaster |
last post by:
In .NET Forms you could Dock a control to an edge of it's parent container. However there does not seem to be anything like this in WPF. Right now I am writing an app that needs to run Full-Screen, but the main Image I am trying to use is not resizing with the rest of the window when I put it in Full-Screen Mode. This Image is incredibly large (2500x1900) so when I set the Height and Width to AUTO the Image blows up. Any ideas or suggestions??
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
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...
| |