Se connecter avec
S'enregistrer | Connectez-vous

Petite question rapide, mettre une balise <script> dans un background

Dernière réponse : dans Programmation

Bonjour!
Voilà ma question, j'ai ce code :

  1. <td width="770" height="163" background="[b]ICI[/b]">
  2. <table width="690" height="120" border="0" align="center" cellpadding="0" cellspacing="0">


Et j'aimerais mettre ce script :
  1. <SCRIPT language="JavaScript">
  2. banniere();
  3. </SCRIPT>


à la place de ICI

Malheuresement,
  1. <td width="770" height="163" background="<SCRIPT language="JavaScript">
  2. banniere();
  3. </SCRIPT>">


Ca ne marche pas.

Merci d'avance!
Lassé par la pub ? Créez un compte
Expert Programmation

un code javascript ne s'inclue pas dans un élément style ou dans une balise ouverte.

Montre nous les 10 ligne du dessus, et les 10 en dessous pour y voir déja un peut plus clair.

Que dois faire ton script ? un affichage de bannière ?

Ouai, des bannière qui s'affiche aléatoirement à chaque chargement de page

Y'a pas grand chose à rajouter

  1. <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  2. <tr>
  3. <td background="images/Header_Bg.gif"> </td>
  4. <td width="770" height="163" background="C'EST ICI QUE JE VEUX METTRE MA BANNIERE QUI CHANGE ALEATOIREMENT">
  5. <table width="690" height="120" border="0" align="center" cellpadding="0" cellspacing="0">
  6. <tr>
  7. <td width="430" height="80"> </td>
  8. <td width="260" height="80"> </td>
  9. </tr>
  10. <tr>
  11. <td width="430" height="40"> </td>
  12. <td width="260" height="40"><table width="260" height="38" border="0" cellpadding="0" cellspacing="0">
  13. <tr>
  14. <td width="6" height="38"><img src="images/recherche_Droit.gif" width="6" height="38" /></td>
  15. <td height="38" valign="middle" background="images/recherche_Bg.gif"><table width="225" height="10" border="0" align="center" cellpadding="0" cellspacing="0">


J'ai essayé de ne pas mettre le script dans la balise background mais à après, ça marche très bien mais le site est déformé :/ 


Quand au script, voilà la totalité :
  1. <html>
  2. <head>
  3. <!-- DEBUT DU SCRIPT -->
  4. <SCRIPT LANGUAGE="JavaScript">
  5. /*
  6. SCRIPT EDITE SUR L'EDITEUR JAVASCRIPT
  7. <a href="http://www.editeurjavascript.com" target="_blank">http://www.editeurjavascript.com</a>
  8. */
  9.  
  10. var nbimage= 70;
  11. var width;
  12. var height;
  13. var url;
  14. var alte;
  15. function banniere()
  16. {
  17. numimage= Math.round(Math.random()*(nbimage-1)+1);
  18. if (numimage <= 10)
  19. {
  20. gotosite = "";
  21. url = "images/header.jpg";
  22. alte = "";
  23. }
  24. if (numimage > 10 && numimage <= 20)
  25. {
  26. gotosite = "";
  27. url = "images/header_ara.jpg";
  28. alte = "";
  29. }
  30. if (numimage > 20 && numimage <= 30)
  31. {
  32. gotosite = "";
  33. url = "images/header_japs1.jpg";
  34. alte = "";
  35. }
  36. if (numimage > 30 && numimage <= 40)
  37. {
  38. gotosite = "";
  39. url = "images/header_obama.jpg";
  40. alte = "";
  41. }
  42. if (numimage > 40 && numimage <= 50)
  43. {
  44. gotosite = "";
  45. url = "images/header_saix.jpg";
  46. alte = "";
  47. }
  48. if (numimage > 50 && numimage <= 60)
  49. {
  50. gotosite = "";
  51. url = "images/header_tag.jpg";
  52. alte = "";
  53. }
  54. if (numimage > 60)
  55. {
  56. gotosite = "";
  57. url = "images/header_japs2.jpg";
  58. alte = "";
  59. }
  60. if(gotosite != "")
  61. {
  62. document.write ('<A HREF="' + gotosite + '">');
  63. }
  64. document.write('<IMG SRC="' + url + '" ALT="' + alte + '" BORDER=0>')
  65. if(gotosite != "")
  66. {
  67. document.write('</A>')
  68. }
  69. }
  70. </SCRIPT>
  71. <!-- FIN DU SCRIPT -->
  72. </head>
  73. <body>
  74. <SCRIPT language="JavaScript">
  75. banniere();
  76. </SCRIPT>
  77. </body>
  78. </html>


Merci !
Expert Programmation

Tu ne peut pas rendre cliquable une image en background.
Tout ce que tu peut faire, c'est l'affichée.

A priori tu as tes 2 lignes dont tu ne te sert pas :

# <tr>
# <td width="430" height="80"> </td>
# <td width="260" height="80"> </td>
# </tr>

Remplace les par :

<tr>
<td width="690" height="80" colspan="2"><SCRIPT language="JavaScript">banniere();</SCRIPT></td>
</tr>

enfaite c'est mon header tout simplement mais comme c'est un kit il est dans le " background ", les dimension sont celle indiqué dans le script, ceux de bases.

J'ai essayé ce que tu m'as dis et ... ça marche " mieu " que tout ce que j'ai essayé mais c'est quand même déformé.

Edit : j'me suis débrouiller pour que ça marche. J'ai viré une ligne de tableau où y'avais une module de recherche.
Merci !
Lassé par la pub ? Créez un compte
Tom's guide dans le monde