nickiller | Bonjour,
Je veux faire des boutons graphiques dynamiques pour tester un site mais malheureusement ça ne marche pas tout le temps. Voici le code:
Code :
- <?xml version="1.0"?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Menu</title>
- <script type="text/javascript">
- var home_n = new Image(); home_n.src = "Images/buttons/home.jpg";
- var home_l = new Image(); home_l.src = "Images/buttons/home_active.jpg";
- var cn_n = new Image(); cn_n.src = "Images/buttons/cn.jpg";
- var cn_l = new Image(); cn_l.src = "Images/buttons/cn_active.jpg";
- var js_n = new Image(); js_n.src = "Images/buttons/js.jpg";
- var js_l = new Image(); js_l.src = "Images/buttons/js_active.jpg";
- var london_china_n = new Image(); london_china_n.src = "Images/buttons/london_china.jpg";
- var london_china_l = new Image(); london_china_l.src = "Images/buttons/london_china_active.jpg";
- var finland_n = new Image(); finland_n.src = "Images/buttons/finland.jpg";
- var finland_l = new Image(); finland_l.src = "Images/buttons/finland_active.jpg";
- var 4ltrophy_n = new Image(); 4ltrophy_n.src = "Images/buttons/4ltrophy.jpg";
- var 4ltrophy_l = new Image(); 4ltrophy_l.src = "Images/buttons/4ltrophy_active.jpg";
- var enquiry_n = new Image(); enquiry_n.src = "Images/buttons/enquiry.jpg";
- var enquiry_l = new Image(); enquiry_l.src = "Images/buttons/enquiry_active.jpg";
- function change_image(image_number, image_object)
- {
- document.images[image_number].src = image_object.src;
- }
- </script>
- </head>
- <body bgcolor="black" face="Comic sans MS" vlink="#7FFFD4" alink="blue" link="#9932CC">
- <font color="white"><h2>Menu</h2><br></font>
- <a href="home.html" target="main" onMouseOut="change_image(0, home_n)" onMouseOver="change_image(0, home_l)">
- <img src="Images/buttons/home.jpg" border="0"></a>
- <a href="cn.html" target="main" onMouseOut="change_image(1, cn_n)" onMouseOver="change_image(1, cn_l)">
- <img src="Images/buttons/cn.jpg" border="0"></a><br>
- <a href="js.html" target="main" onMouseOut="change_image(2, js_n)" onMouseOver="change_image(2, js_l)">
- <img src="Images/buttons/js.jpg" border="0"></a><br>
- <a href="http://gabarra.info" target="main" onMouseOut="change_image(3, london_china_n)"
- onMouseOver="change_image(3, london_china_l)">
- <img src="Images/buttons/london_china.jpg" border="0"></a><br>
- <a href="http://nico.efrei.free.fr" target="main" onMouseOut="change_image(4, finland_n)"
- onMouseOver="change_image(4, finland_l)">
- <img src="Images/buttons/finland.jpg" border="0"></a><br>
- <a href="http://4ltrophy.info" target="main" onMouseOut="change_image(5, 4ltrophy_n)" onMouseOver="change_image(5, 4ltrophy_l)">
- <img src="Images/buttons/4ltrophy.jpg" border="0"></a><br>
- <a href="enquiry.html" target="main" onMouseOut="change_image(6, enquiry_n)" onMouseOver="change_image(6, enquiry_l)">
- <img src="Images/buttons/enquiry.jpg" border="0"></a><br>i<br><br>
- <a href="mailto:nico.gab@gmail.com" valign="baseline">nico.gab@gmail.com</a>
- </body>
- </html>
|
Il se trouve que lorsqu'il n'y a, par exemple, que les lignes
Code :
- var home_n = new Image(); home_n.src = "Images/buttons/home.jpg";
- var home_l = new Image(); home_l.src = "Images/buttons/home_active.jpg";
- var cn_n = new Image(); cn_n.src = "Images/buttons/cn.jpg";
- var cn_l = new Image(); cn_l.src = "Images/buttons/cn_active.jpg";
|
Ca marche. Je ne comprend pas car le code a pourtant l'air correcte. Si quelqu'un voit une erreur qu'il n'hésite pas
Voici le lien du site http://www.cc.puv.fi/~e0600929/.
Merci et bonne journée. Message édité par nickiller le 01-12-2006 à 18:19:43
|