|
#1
|
|||
|
|||
|
javascript onmouseclick
Hello,
This is continued from a question I asked http://cybertechhelp.com/forums/showthread.php?t=22796 but I htought it would be more use to people if I asked my next q in a separate thread. I have created a simple web page. I want images called one and two to change when I have clicked on the image. HOwever it does not work. It would when I do onmousedown and onmouseup but not onmouseclick. Ithink it is summit to do with my href becuase it calls the page again and so loads up the original image. THe code fo the page is: <HTML> <HEAD> <SCRIPT> Rollimage = new Array() Rollimage[0] = new Image(250,175) Rollimage[0].src = "images/one.jpg" Rollimage[1] = new Image(250,175) Rollimage[1].src = "images/two.jpg" function Clicker(number){ if (number == 1) { document.IM1.src = Rollimage[1].src; return true; } if (number == 2) { document.IM2.src = Rollimage[1].src; return true; } } </SCRIPT> </HEAD> <BODY> <TABLE width="80%" align = center border=1> <TR> <TD><A onmousedown=Clicker(1) href="index.html"> <IMG src="images/one.jpg" border=0 name=IM1> </A> </TD> </TR> <TR> <TD><A onmouseclick=Clicker(2)href="index.html"> <IMG src="images/one.jpg" border=0 name=IM2> </A> </TD> </TR> </TABLE> </BODY> </HTML> It is a table with two rows. One to show onmousedown works. the next row is the onmouseclick adn this doesnt work! Any ideas? Thanks Richard Last edited by RichardJones; September 18th, 2003 at 02:58 PM. |
|
#2
|
||||
|
||||
|
Is onclick not onmouseclick.
Also, remember to use quotes and in javascript start from zero not one. Code:
<HTML>
<HEAD>
<SCRIPT>
Rollimage = new Array()
Rollimage[0] = new Image(250,175)
Rollimage[0].src = "http://www.cybertechhelp.com/forums/images/newthread.gif"
Rollimage[1] = new Image(250,175)
Rollimage[1].src = "http://www.cybertechhelp.com/forums/images/reply.gif"
function Clicker(number){
if (number == 0)
{
document.IM1.src = Rollimage[1].src;
return true;
}
if (number == 1)
{
document.IM2.src = Rollimage[0].src;
return true;
}
}
</SCRIPT>
</HEAD>
<BODY>
<TABLE width="80%" align = center border=1>
<TR>
<TD><A onmousedown="Clicker(0)" href="#">
<IMG src="http://www.cybertechhelp.com/forums/images/newthread.gif" border="0" name="IM1">
</A>
</TD>
</TR>
<TR>
<TD><A onclick="Clicker(1)" href="#">
<IMG src="http://www.cybertechhelp.com/forums/images/reply.gif" border="0" name="IM2">
</A>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
__________________
Cheers, Degs Please post back with your results CTH Terms of Use CTH Subscriptions :: Adaware Guide :: HijackThis |
|
#3
|
|||
|
|||
|
Thanks for your help degsy
|
![]() |
| Bookmarks |
«
Previous Topic
|
Next Topic
»
| Topic Tools | |
|
|
All times are GMT +1. The time now is 03:36 AM.
[
RSS ]








