User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 397,760 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,506 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Jun 19th, 2008
Views: 1,114
First take two images named with smirk1.jpg and smirk2.jpg with same size
paste below code and for Image write this code

<IMG src="smirk1.jpg" name="smirk" onMouseOver="over(0);" onMouseOut="out(0);" />
javascript Syntax
  1. <script type="text/javascript">
  2. var revert = new Array();
  3. var inames = new Array('smirk');
  4.  
  5. // Preload
  6. if (document.images) {
  7. var flipped = new Array();
  8. for(i=0; i< inames.length; i++) {
  9. flipped[i] = new Image();
  10. flipped[i].src = ""+inames[i]+"2.JPG";
  11. }
  12. }
  13.  
  14. function over(num) {
  15. if(document.images) {
  16. revert[num] = document.images[inames[num]].src;
  17. document.images[inames[num]].src = flipped[num].src;
  18. }
  19. }
  20. function out(num) {
  21. if(docu <script type="text/javascript">
  22. var revert = new Array();
  23. var inames = new Array('smirk');
  24.  
  25. // Preload
  26. if (document.images) {
  27. var flipped = new Array();
  28. for(i=0; i< inames.length; i++) {
  29. flipped[i] = new Image();
  30. flipped[i].src = ""+inames[i]+"2.JPG";
  31. }
  32. }
  33.  
  34. function over(num) {
  35. if(document.images) {
  36. revert[num] = document.images[inames[num]].src;
  37. document.images[inames[num]].src = flipped[num].src;
  38. }
  39. }
  40. function out(num) {
  41. if(document.images) document.images[inames[num]].src = revert[num];
  42. }
  43. </script>
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 3:53 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC