Results 1 to 5 of 5
Thread: A quick tip for complete beginners for JS: Rollover images
-
A quick tip for complete beginners for JS: Rollover images
19 May 2009 @ 09.26 To avoid writing painfully long JS for it, I've fount that it's easier to simply write this:
Which is written in the HTML like this:Code:<script type="text/javascript"> function over() { document.button1.src ="image2.gif" //This event occurs the rollover } function out() { document.button1.src ="image1.gif" //This is the original image that returns after the mouse has been moved away from the image } </script>
Just thought about it now.Code:<img src="image1.gif" onMouseover="over()" onMouseout"out()" name="button1" alt="image" />
Boris Johnson for future PM!
-
19 May 2009 @ 14.34 It's bad practise to add all the onMouseOver stuff to the element itself. You should give it an id and select it:
And do this:Code:var myImg = document.getElementById("imgid");
Code:myImg.onMouseover = over(); myImg.onMouseout = out();
Site: jackfranklin.co.uk Blog: ispeakwebstuff.co.uk Project: learnitscreencasts.co.uk
I'm available for 1 to 1 lessons on HTML/CSS/PHP/Javascript/jQuery/Photoshop/Fireworks so please PM Me!
-
19 May 2009 @ 15.16 Thanks. Never thought it could be written like that!
Boris Johnson for future PM!
-
19 May 2009 @ 15.37 sorry, but I still prefer css, you can do that anyway and it cant be switched off
-
19 May 2009 @ 20.17 True, but sometimes I fancy writing some JS for it.
Boris Johnson for future PM!
Similar Threads
-
Quick chuckle
By Frinkky in forum Coffee HouseReplies: 5Last Post: 22 Jun 2010, @ 10.43 -
Complete Server Back-Up Help
By Wrams in forum Server ManagementReplies: 3Last Post: 5 Oct 2009, @ 12.41 -
Beginners Help
By Tom in forum SEO (Search Engine Optimisation) & Search EnginesReplies: 4Last Post: 23 Jun 2009, @ 12.25 -
A Quick Question
By A800 in forum Coffee HouseReplies: 5Last Post: 2 Jun 2009, @ 09.28



LinkBack URL
About LinkBacks











Help needed please
Can you link to a web page showing the problem? That makes it much...