onmousedown onmouseup

N

NeilCarmichael

I am flummoxed, I'm relatively new to javascript and I can't get my
onmousedown onmouseup script to work.

simply, I want to fire one function when I click down on a graphic and
a second when I release.

I tried different combinations of onmousedown onmouseup and onclick
and putting them in div's img's and anchor's but I can't get it to
work, any ideas?

<IMG SRC="down.png" alt="fade channel down"
onmousedown="javascript:SetDynet('a=<%=a%>&amp;c=<%=x
%>&amp;l=0&amp;f=2')" onMouseUp="javascript:SetDynet('a=<%=a
%>&amp;p=88')" /></center>
 
L

Lee

NeilCarmichael said:
I am flummoxed, I'm relatively new to javascript and I can't get my
onmousedown onmouseup script to work.

simply, I want to fire one function when I click down on a graphic and
a second when I release.

I tried different combinations of onmousedown onmouseup and onclick
and putting them in div's img's and anchor's but I can't get it to
work, any ideas?

<IMG SRC="down.png" alt="fade channel down"
onmousedown="javascript:SetDynet('a=<%=a%>&amp;c=<%=x
%>&amp;l=0&amp;f=2')" onMouseUp="javascript:SetDynet('a=<%=a
%>&amp;p=88')" /></center>

Have you considered that the problem might be in your server
side code or in "SetDynet()"?

It's generally a waste of time to post server-side code for
debugging. The problem could easily be in whatever is being
substituted for "<%=a%>".

Try the following. It works for me in Firefox and IE:

<html>
<body>
<img src="down.png"
onmousedown="alert('down')"
onmouseup="alert('up')"</body>
</html>


--
 
R

Robin

NeilCarmichael said:
I am flummoxed, I'm relatively new to javascript and I can't get my
onmousedown onmouseup script to work.

simply, I want to fire one function when I click down on a graphic and
a second when I release.

I tried different combinations of onmousedown onmouseup and onclick
and putting them in div's img's and anchor's but I can't get it to
work, any ideas?

<IMG SRC="down.png" alt="fade channel down"
onmousedown="javascript:SetDynet('a=<%=a%>&amp;c=<%=x
%>&amp;l=0&amp;f=2')" onMouseUp="javascript:SetDynet('a=<%=a
%>&amp;p=88')" /></center>

What are the "javascript:"s doing in the values for the onmouseup and
onmousedown attributes? They aren't like the href of an <a> which
specifies a URI (and you shouldn't be using javascript: in them either
any more). The value of the onmousedown and onmouseup (and all other
onXXX) atttributes should be just javascript code.

i.e.
<img src='down.png'
onmousedown='SetDynet(...)'
onmouseup='SetDynet(...)' />

Also, if your using xhtml tagging (e.g. <img />) then you shouldn't be
also using <center> which is no longer strictly supported in xhtml. (a
simple <div style='text-align:center'> should do the trick.

Robin
 
T

Thomas 'PointedEars' Lahn

Robin said:
Also, if your using xhtml tagging (e.g. <img />) then you shouldn't be
also using <center> which is no longer strictly supported in xhtml. (a
simple <div style='text-align:center'> should do the trick.

Good solution, wrong reasoning. Contrary to popular belief, the intent and
purpose of XHTML 1.0 is _not_ to separate logic and presentation (HTML 4.01
already did that with introducing style sheet support), but to provide for
*(syntactically) well-formed XML-compatible documents* and to make use of
the advantages of that. Hence both HTML 4.01 _Transitional_ and XHTML 1.0
_Transitional_ support the `center' element for backwards compatibility --
*transitional* purpose --, but neither HTML 4.01 _Strict_ nor XHTML 1.0
_Strict_ or XHTML 1.1 do.

That said, it is well-known among competent Web developers that *properly
served* XHTML *alone* hardly is an option on the Web nowadays. Especially
when it comes to backwards compatible DOM scripting.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top