473,387 Members | 1,379 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,387 software developers and data experts.

Need help with onmouseclick

I have this code below to do a rollover image. IT doesnt work with the
onmouseclick event. But it wil lwork fine with the onmouseover so when the
user hovers over the image, the main image changes. I am trying to do an
onmouseclick event so when the user clicks on the link, it will change the
main image, but it doesnt work. What can I do?

<img name="rollover" src="/images/image1.jpg" border=0 width="200"
height="300" >

<a href onmouseclick='rollover.src = "/images/image2.jpg"'
onmouseout='rollover.src="/images/image1.jpg"'> <img
src="/images/image2.jpg" border=0 width=75 height=100></a>


Jul 23 '05 #1
1 24857
On Sun, 28 Nov 2004 11:07:22 -0500, Danny <da********@hotmail.com> wrote:
I have this code below to do a rollover image. IT doesnt work with the
onmouseclick event.
That's because there's no such intrinsic event: it's click (onclick as an
attribute).

[snip]
<img name="rollover"
Unless you actively care about old browsers, id the image

<img id="rollover" ...>
src="/images/image1.jpg" border=0
The border attribute is deprecated. Use CSS to style documents.

[snip]
<a href
The appropriate URL here would be the image. This would mean that visitors
that don't have scripting enabled can navigate to, and see, your image.
onmouseclick='rollover.src = "/images/image2.jpg"'
Relying the user agent's ability to resolve name or id values as global
variables is risky, and will frequently fail. To access an IMG element,
use the images collection:

document.images['imageName-or-Id'].src = '...';

You'll also need to cancel the click event. If you don't, the browser will
continue to request the linked resource after the script has executed. You
do that by returning false from the event listener.

<a href="/images/image2.jpg"
onclick="changeImg(this.href); return false;">

where changeImg is

function changeImg(url) {
document.images['rollover'].src = url;
}
<img src="/images/image2.jpg" border=0 width=75 height=100></a>


Both here, and earlier, you have omitted the alt attribute on the IMG
element. Don't.

Hope that helps,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2

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

Similar topics

0
by: Sofia | last post by:
My name is Sofia and I have for many years been running a personals site, together with my partner, on a non-profit basis. The site is currently not running due to us emigrating, but during its...
7
by: Mike Kamermans | last post by:
I hope someone can help me, because what I'm going through at the moment trying to edit XML documents is enough to make me want to never edit XML again. I'm looking for an XML editor that has a...
15
by: drdoubt | last post by:
using namespace std In my C++ program, even after applying , I need to use the std namespace with the scope resolution operator, like, std::cout, std::vector. This I found a little bit...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
3
by: Bob.Henkel | last post by:
I write this to tell you why we won't use postgresql even though we wish we could at a large company. Don't get me wrong I love postgresql in many ways and for many reasons , but fact is fact. If...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
4
by: Phil | last post by:
k, here is my issue.. I have BLOB data in SQL that needs to be grabbed and made into a TIF file and placed on the client (could be in temp internet dir). The reason we need it in TIF format is...
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
1
by: shabam | last post by:
hi there, I am wondering how i can go about loading an array with quicktime videos then using js to dynamically embedd movies as they are needed into the webpage (if it is possible?) I have a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.