Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Swap image without name tag.

Reply
Thread Tools

Swap image without name tag.

 
 
Joachim
Guest
Posts: n/a
 
      04-27-2006

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
 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      04-27-2006
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.


 
Reply With Quote
 
 
 
 
marss
Guest
Posts: n/a
 
      04-28-2006

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';" ....

 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      04-28-2006
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
 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      04-28-2006
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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
next / previous image swap WITH larger image popup Clay Javascript 1 09-28-2006 09:07 PM
What swap is called when using std::swap? Niels Dekker (no reply address) C++ 4 07-20-2006 08:44 PM
Want to swap HD's without altering jumpers Win XP Mac Lynch Computer Support 7 07-18-2005 01:52 AM
swap two integers without using a tmp variable? Steve C++ 50 06-25-2004 06:23 PM
Mouse-over an image -> play video instead of swap image? Phillip Roncoroni HTML 6 04-06-2004 06:57 AM



Advertisments