| | |
Image Swap with the Mouse
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Swap two images as you move your mouse in and out of the image field. Uses onMouseOver, onMouseOut and a short javascript code.
<!-- Experiments with images vegaseat 6/15/04 --> <!-- onMouseOver, onMouseOut, JS --> <html> <head> <title>Swap Images with onMouseOver and onMouseOut</title> </head> <body bgcolor="#FFFFCC" text="#3300FF"> <CENTER> <FORM NAME = form1> <H2> Move the mouse across to swap the image ... </H2> <A HREF="" name= link1 onMouseOver = "ImgOver()" onMouseOut = "ImgOut()"> <IMG NAME = "IMG1" SRC = "c:/windows/web/wallpaper/follow.jpg" WIDTH = 800 HEIGHT = 600> </A> </CENTER> <SCRIPT LANGUAGE= JavaScript> function ImgOver() { // use an image file you have or use one of XP's wallpaper document.form1.IMG1.src = 'c:/windows/web/wallpaper/home.jpg'; } function ImgOut() { // use an image file you have or use one of XP's wallpaper document.form1.IMG1.src = 'c:/windows/web/wallpaper/follow.jpg'; } </SCRIPT> </body> </html>
0
•
•
•
•
Is no closing <form> tag required here? What could you use to give a name to instead of a form to refer to in the document.whatever.IMG1.src line? I've tried using several things I give names to but they don't work. Hmm..
Take a break and go to:
Check out: http://www.wsiwebsitestudio.com/thebeat.html
Take a break and go to:
Check out: http://www.wsiwebsitestudio.com/thebeat.html
0
•
•
•
•
Another excellent article about Javascript. It is widely used on the web and is very convenient for web developers.
http://www.1-satellite-tv-facts.com
http://www.1-satellite-tv-facts.com/Direct-TV.html
http://www.1-satellite-tv-facts.com/Dish-Network.html
http://www.1-satellite-tv-facts.com/...ite-Radio.html
http://www.1-satellite-tv-facts.com/...t-Service.html
http://www.1-satellite-tv-facts.com/Satellite-DSL.html
http://www.1-satellite-tv-facts.com/...-Internet.html
http://www.1-satellite-tv-facts.com/VoIP.html
http://www.1-satellite-tv-facts.com/Phone-Systems.html
http://www.1-satellite-tv-facts.com/...-Programs.html
http://www.1-satellite-tv-facts.com
http://www.1-satellite-tv-facts.com/Direct-TV.html
http://www.1-satellite-tv-facts.com/Dish-Network.html
http://www.1-satellite-tv-facts.com/...ite-Radio.html
http://www.1-satellite-tv-facts.com/...t-Service.html
http://www.1-satellite-tv-facts.com/Satellite-DSL.html
http://www.1-satellite-tv-facts.com/...-Internet.html
http://www.1-satellite-tv-facts.com/VoIP.html
http://www.1-satellite-tv-facts.com/Phone-Systems.html
http://www.1-satellite-tv-facts.com/...-Programs.html
0
•
•
•
•
the code is unneccessarily complex
<img src='image1.jpg' onmouseover='src="image2.jpg";' onmouseout='src="image1.jpg";'>
the only javascript required is to load the second image in the background after the page is loaded and displayed, so there is no mouseover delay
[icode] ...snip ..
</body>
<script language="javascript" type="text/javascript">
//<![CDATA[
<!--
image2 = new Image();
image2.src = "image2.jpg";
//-->
//]]>
</script>
</html>[/icode}
<img src='image1.jpg' onmouseover='src="image2.jpg";' onmouseout='src="image1.jpg";'>
the only javascript required is to load the second image in the background after the page is loaded and displayed, so there is no mouseover delay
[icode] ...snip ..
</body>
<script language="javascript" type="text/javascript">
//<![CDATA[
<!--
image2 = new Image();
image2.src = "image2.jpg";
//-->
//]]>
</script>
</html>[/icode}
Similar Threads
- image swap (JavaScript / DHTML / AJAX)
- Onclick swap image and swap text in div (JavaScript / DHTML / AJAX)
- A new image swap? (JavaScript / DHTML / AJAX)
- Help with SWAP IMAGE (Site Layout and Usability)
- Image Swap help (HTML and CSS)
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
acid2 ajax ajaxcode ajaxhelp animate array automatically autoplay beta boarder box bug button calendar captcha card cart codes column cookies createrange() css cursor date debugger decimal design developer dom download dropdown element enter error events firefox firehose flash focus form frameworks getselection google gwt html htmlform iframe image() index java javascript javascripts jawascriptruntimeerror jquery jsp listbox maps marquee masterpage menu microsoft mimic mp3 mp4 offline onmouseover parameters php player post problem programming progressbar prototype rating redirect regex safari scale scriptlets search select size sources sql starrating text textarea toggle twitter validation variables w3c web website window windowofwords windowsxp xml xspf



