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

Swap image without name tag.


Hi.

I have a function that swap images. But in the image element i use the tag
"name" to give name that i send to my java script function:

<img src="greensmiley.jpg" name="smiley" alt="gubbe" onmouseover="swapImage('smiley',
'CoolSmiley.jpg')" onmouseout="swapImage('smiley','greensmiley.jpg')" />

But to have a valid xhtml1.1 document you cant use the "name" tag. I've tried
with the id tag but then my function dont work. Is there any other tag to
use? Or how do you solve this?

Best regards Joachim
Apr 27 '06 #1
4 1721
Joachim wrote:
I have a function that swap images. But in the image element
i use the tag "name"
It is an attribute not a tag.
to give name that i send to my java script function:

<img src="greensmiley.jpg" name="smiley" alt="gubbe"
onmouseover="swapImage('smiley', 'CoolSmiley.jpg')"
onmouseout="swapImage('smiley','greensmiley.jpg')" />

But to have a valid xhtml1.1 document you cant use the
"name" tag. I've tried with the id tag but then my
function dont work.

<snip>

Then you change the function so that it does work. In an XHTML DOM it
should be possible to reference an IDed IMG element through the -
document.images - collection, or use document.getElementById to retrieve
a reference to it.

Richard.
Apr 27 '06 #2

Joachim написав:
Hi.

I have a function that swap images. But in the image element i use the tag
"name" to give name that i send to my java script function:

<img src="greensmiley.jpg" name="smiley" alt="gubbe" onmouseover="swapImage('smiley',
'CoolSmiley.jpg')" onmouseout="swapImage('smiley','greensmiley.jpg')" />

But to have a valid xhtml1.1 document you cant use the "name" tag. I've tried
with the id tag but then my function dont work. Is there any other tag to
use? Or how do you solve this?

You can use "this" keyword in the event handler. "this" is the object
captured event.

html:
<img onmouseover="swapImage(this, 'CoolSmiley.jpg')"
onmouseout="swapImage(this,'greensmiley.jpg')" ....

javascript:
function swapImage(sender, imgSrc){
sender.src = imgSrc;
}

Or, more simpler:
<img onmouseover="this.src='CoolSmiley.jpg';"
onmouseout="this.src='greensmiley.jpg';" ....

Apr 28 '06 #3
Joachim wrote:
I have a function that swap images. But in the image element i use the tag
"name" to give name that i send to my java script function:
"java script"?
<img src="greensmiley.jpg" name="smiley" alt="gubbe"
onmouseover="swapImage('smiley', 'CoolSmiley.jpg')"
onmouseout="swapImage('smiley','greensmiley.jpg')" />
<URL:http://pointedears.de/hoverMe/>
But to have a valid xhtml1.1 document you cant use the "name" tag.


Certainly you don't need or want XHTML 1.1 these times. And most certainly
you do not even need or want XHTML these times. Search the archives.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Apr 28 '06 #4
Thomas 'PointedEars' Lahn said the following on 4/28/2006 9:12 AM:
Joachim wrote:
I have a function that swap images. But in the image element i use the tag
"name" to give name that i send to my java script function:


"java script"?


Yes, moron, that is what he said. Your overly pedantic idiotic behavior
is displaying itself again.
<img src="greensmiley.jpg" name="smiley" alt="gubbe"
onmouseover="swapImage('smiley', 'CoolSmiley.jpg')"
onmouseout="swapImage('smiley','greensmiley.jpg')" />


<URL:http://pointedears.de/hoverMe/>


And then don't.
But to have a valid xhtml1.1 document you cant use the "name" tag.


Certainly you don't need or want XHTML 1.1 these times. And most certainly
you do not even need or want XHTML these times. Search the archives.


Finally, something that makes sense came from you.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 28 '06 #5

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

Similar topics

3
by: Randell D. | last post by:
Folks, I'm still learning javascript - I've invested in a couple of books and reading online as much as possible. I'm pretty sure what I am suggesting is possible though I'm trying to weigh up...
12
by: LAshooter | last post by:
I have a portfolio page which loads a dozen thumbnails and one large image. A friend helped me code a script (below) which will swap out the large image (named "imgLarg") when a different thumbnail...
7
by: KiwiBrian | last post by:
On a web page I have a graphic for a Shopping Cart Submit button. It is within a form and working fine. I would like to perform an image swap to an identical graphic of a different colour when I...
3
by: PEJO | last post by:
I'm not much of a JS programmer so I used the the standard Macromedia swap image function for a disjointed rollover..which works fine.. no problem swapping the image with that code.... but when...
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,...
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...

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.