Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1554 connectés 

  FORUM HardWare.fr
  Programmation
  HTML/CSS

  Besoin d 'aide pour combiner 2 script Javascript.

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Besoin d 'aide pour combiner 2 script Javascript.

n°1904659
senka
Only Geek
Posté le 12-07-2009 à 07:05:27  profilanswer
 

Bonjours à tous,
 
J'ai besoin de faire un menu assez particulier. Un menu qui n'a pas une forme standard si on peu dire.
 
Pour réalisé ceci, j'ai donc utilisé la balise <map> affin que mes boutons ai une zone bien spécifique de sélection.
J'y suis arrivé et voici le résultat que vous pouvez voir ici :
senka.hd.free.fr...
 
Perso je trouve que c'est assez simpa, mais ca pourrais l'être encore plus avec un effet de "fading" sur chacun des boutons.
voir l'exemple du fading : senka.hd.free.fr...
Biensur, j'ai pu récuprer pas mal de script proposant cette effet, mais la ou je bloque, c'est pour adapté cette effet de fading sur mon menu à moi. Et je viens donc faire appel à vous et vos connaissances pour m'aider car j'ai très peu de conaissance en javascript et je galère pas mal.
 
Voila, j'espère qu'il y aura quelqu'un qui saura m'aider avant que je perde tout mes cheveux ^^
 
Je vous colle le code ici au cas ou :
 
Le menu graphique normal :

Code :
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Supermenu Test By 5k</title>
  6. </head>
  7. <script type="text/javascript" language="javascript">
  8.  preload_image('img/bouton_1.gif');
  9.  preload_image('img/bouton_2.gif');
  10.  preload_image('img/bouton_3.gif');
  11.  preload_image('img/bouton_4.gif');
  12.  preload_image('img/bouton_5.gif');
  13.  preload_image('img/bouton_6.gif');
  14. function change_image(number) {
  15. var ShowItem = document.getElementById("selection" );
  16. ShowItem.style.backgroundImage = 'url(img/bouton_' + number + '.gif)';
  17. return true;
  18. }
  19. function hide_image(number) {
  20. var ShowItem = document.getElementById("selection" );
  21. ShowItem.style.backgroundImage = 'url(img/transparent.gif)';
  22. return true;
  23. }
  24. </script>
  25. <style>
  26. html, body {margin:0px;}
  27. body {background:url(img/background.gif) no-repeat #4a4a4a;}
  28. img {border-style:none;}
  29. div {height:288px; width:218px; background:url(img/menu.jpg) no-repeat; margin:96px 0px 0px 123px;}
  30. </style>
  31. <body>
  32. <div><img id="selection" src="img/transparent.gif" usemap="#menu"></div>
  33. <map name="menu">
  34. <area shape="poly" coords="4,3,199,72,201,101,12,55" href="http://www.google.fr" onmouseover="change_image(1)" onmouseout="hide_image(1)">
  35. <area shape="poly" coords="13,56,201,101,203,130,20,105" href="http://www.google.fr" onmouseover="change_image(2)" onmouseout="hide_image(2)">
  36. <area shape="poly" coords="20,105,204,130,206,158,28,152" href="http://www.google.fr" onmouseover="change_image(3)" onmouseout="hide_image(3)">
  37. <area shape="poly" coords="28,152,206,159,208,186,36,197" href="http://www.google.fr" onmouseover="change_image(4)" onmouseout="hide_image(4)">
  38. <area shape="poly" coords="36,197,208,186,210,212,43,241" href="http://www.google.fr" onmouseover="change_image(5)" onmouseout="hide_image(5)">
  39. <area shape="poly" coords="43,241,210,213,212,239,50,282" href="http://www.google.fr" onmouseover="change_image(6)" onmouseout="hide_image(6)">
  40. </map>
  41. </body>
  42. </html>


 
Le menu non fonctionnel mais avec effet de fading :

Code :
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2.   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  6. <title>Fade Method 2 (single image)</title>
  7. <script type="text/javascript" src="js/jquery.js"></script>
  8. <script type="text/javascript">
  9.     // wrap as a jQuery plugin and pass jQuery in to our anoymous function
  10.     (function ($) {
  11.         $.fn.cross = function (options) {
  12.             return this.each(function (i) {
  13.                 // cache the copy of jQuery(this) - the start image
  14.                 var $$ = $(this);
  15.                
  16.                 // get the target from the backgroundImage + regexp
  17.                 var target = $$.css('backgroundImage').replace(/^url|[\(\)'"]/g, '');
  18.                 // nice long chain: wrap img element in span
  19.                 $$.wrap('<span style="position: relative;"></span>')
  20.                     // change selector to parent - i.e. newly created span
  21.                     .parent()
  22.                     // prepend a new image inside the span
  23.                     .prepend('<img>')
  24.                     // change the selector to the newly created image
  25.                     .find(':first-child')
  26.                     // set the image to the target
  27.                     .attr('src', target);
  28.                 // the CSS styling of the start image needs to be handled
  29.                 // differently for different browsers
  30.                 if ($.browser.msie || $.browser.mozilla) {
  31.                     $$.css({
  32.                         'position' : 'absolute',
  33.                         'left' : 0,
  34.                         'background' : '',
  35.                         'top' : this.offsetTop
  36.                     });
  37.                 } else if ($.browser.opera && $.browser.version < 9.5) {
  38.                     // Browser sniffing is bad - however opera < 9.5 has a render bug  
  39.                     // so this is required to get around it we can't apply the 'top' : 0  
  40.                     // separately because Mozilla strips the style set originally somehow...                     
  41.                     $$.css({
  42.                         'position' : 'absolute',
  43.                         'left' : 0,
  44.                         'background' : '',
  45.                         'top' : "0"
  46.                     });
  47.                 } else { // Safari
  48.                     $$.css({
  49.                         'position' : 'absolute',
  50.                         'left' : 0,
  51.                         'background' : ''
  52.                     });
  53.                 }
  54.                 // similar effect as single image technique, except using .animate  
  55.                 // which will handle the fading up from the right opacity for us
  56.                 $$.hover(function () {
  57.                     $$.stop().animate({
  58.                         opacity: 0
  59.                     }, 250);
  60.                 }, function () {
  61.                     $$.stop().animate({
  62.                         opacity: 1
  63.                     }, 250);
  64.                 });
  65.             });
  66.         };
  67.        
  68.     })(jQuery);
  69.    
  70.     // note that this uses the .bind('load') on the window object, rather than $(document).ready()  
  71.     // because .ready() fires before the images have loaded, but we need to fire *after* because
  72.     // our code relies on the dimensions of the images already in place.
  73.     $(window).bind('load', function () {
  74.         $('img.fade').cross();
  75.     });
  76. </script>
  77. <style>
  78. html, body {margin:0px;}
  79. body {background:url(img/background.gif) no-repeat #4a4a4a;}
  80. img {border:0px;background:url(img/bouton1.jpg) no-repeat;}
  81. div {margin:96px 0px 0px 123px;}
  82. </style>
  83. </head>
  84. <body>
  85. <div><img class="fade" src="img/menu.jpg"/ usemap="#menu"></div>
  86.        
  87. <map name="menu">
  88. <area shape="poly" coords="4,3,199,72,201,101,12,55" href="http://www.google.fr" onmouseover="change_image(1)" onmouseout="hide_image(1)">
  89. </map>
  90. </body>
  91. </html>


 
Certain script de fading que j'ai récup sont plus ou moins présenté ici :
exemple 1 : senka.hd.free.fr...
exemple 2 : senka.hd.free.fr...
exemple 3 : senka.hd.free.fr...
exemple 4 : senka.hd.free.fr...


Message édité par senka le 12-07-2009 à 13:13:43
mood
Publicité
Posté le 12-07-2009 à 07:05:27  profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  HTML/CSS

  Besoin d 'aide pour combiner 2 script Javascript.

 

Sujets relatifs
besoin de vos aidesAfficher texte au survol javascript
javascript envoi mail avec pièce jointe[SQL SERVER 2005] Script de remplissage de table (BLUK INSERT & cie)
aide jquery thickbox passage de variableAide pour alléger une macro
Javascript - Deux formulaires - deux select onchangeScript de téléchargement de fichier
help me, script pour AD boite de dialogue et généré fichier 
Plus de sujets relatifs à : Besoin d 'aide pour combiner 2 script Javascript.


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR