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

  FORUM HardWare.fr
  Programmation
  HTML/CSS

  conflit avec deux javascript

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

conflit avec deux javascript

n°2042999
otasnake
Posté le 18-12-2010 à 10:10:56  profilanswer
 

Mon problème est le suivant : sur le site web que je suis en train de créer, j'aimerais mettre plusieurs visionneuses d'images en javascript sur la même page.  
Les deux scripts marchent séparément mais une fois mis ensemble, ils ne marchent plus...
J'ai fais plusieurs recherches sur internet donc si quelqu'un peut m'aider... ce serait bien! http://forum-images.hardware.fr/icones/smile.gif
 
Je vous mets le code de ma page :  
 
<!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>
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
 background-color: #000;
 color: #FFF;
 font-size: 24px;
 font-family: Verdana, Geneva, sans-serif;
}
.e {
 font-size: 40px;
 font-family: Verdana, Geneva, sans-serif;
}
.R {
 color: #CCC;
}
a:link {
 text-decoration: none;
 color: #CCC;
}
a:visited {
 text-decoration: none;
 color: #CCC;
}
a:hover {
 text-decoration: none;
 color: #FFF;
}
a:active {
 text-decoration: none;
 color: #CCC;
}
</style>
 
<script language="JavaScript">
<!--
//PLF-http://www.jejavascript.net/
function objet() {
this.length = objet.arguments.length
for (var i = 0; i < this.length; i++) this[i+1] = objet.arguments[i]
}
var nom = new objet ("12 APO.jpg", "caverne V2.jpg", "IMG_5385.jpg" );
var numero = 1;
function changer() {
document.image.src = "images/photos/"+nom[numero];
numero += 1;
if (numero == nom.length + 1) numero = 1;
setTimeout("changer()", 2000);
}
 
//-->
 
</script>
<script language="JavaScript">
<!--
//PLF-http://www.jejavascript.net/
function objet() {
this.length = objet.arguments.length
for (var i = 0; i < this.length; i++) this[i+1] = objet.arguments[i]
}
var nom = new objet ("IMG_6328.jpg", "IMG_6339.jpg", "IMG_6350.jpg" );
var numero = 1;
function changer() {
document.image.src = "images/photos/"+nom[numero];
numero += 1;
if (numero == nom.length + 1) numero = 1;
setTimeout("changer()", 2000);
}
//-->
</script>
</head>
 
<body onLoad="changer()">
<table width="1358" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th height="118" class="e" scope="col"><span class="R"><a href="index.htm">ALEXANDRE ROCA</a></span> photographie</th>
  </tr>
  <tr bgcolor="#333333">
    <td height="50" bgcolor="#333333">&nbsp;</td>
  </tr>
  <tr>
    <td height="50"><table width="1358" border="0">
      <tr bgcolor="#999999">
        <td width="335" align="center" bgcolor="#999999" class="AB">Paysages</td>
        <td width="333" align="center" class="AB">Urbains</td>
        <td width="334" align="center" class="AB">Panoramas</td>
        <td width="338" align="center" class="AB">Noirs et Blancs</td>
      </tr>
    </table></td>
  </tr>
  <tr bgcolor="#333333">
    <td height="50">&nbsp;</td>
  </tr>
  <tr bgcolor="#000000">
    <td height="107"><table width="1358" border="0">
      <tr bgcolor="#999999">
        <td width="340"><img src="images/photos/12 APO.jpg" width="336" height="231" name="image">&nbsp;</td>
        <td width="338"><img src="images/photos/IMG_6328.jpg" width="336" height="231" name="image">&nbsp;</td>
        <td width="339">&nbsp;</td>
        <td width="341">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>

mood
Publicité
Posté le 18-12-2010 à 10:10:56  profilanswer
 

n°2043066
otasnake
Posté le 19-12-2010 à 00:46:44  profilanswer
 

Un petit up car j'ai vraiment besoin d'aide! please!

n°2043105
smaragdus
whores, drugs & J.S. Bach
Posté le 19-12-2010 à 12:36:13  profilanswer
 

Première étape :
 
Que dit la console Javascript ?

n°2043188
gatsu35
Blablaté par Harko
Posté le 19-12-2010 à 23:33:38  profilanswer
 

Ya même pas besoin d'étape là, il mets 2x le même script, mêmes fonctions, donc les premières déclarations sont écrasés par la deuxième déclaration
 
premiere chose ne jamais aller sur les sites de merde comme Jejavascript et editeurjavascript. Ces sites ne font que proposer du code de merde.


Message édité par gatsu35 le 19-12-2010 à 23:35:16

---------------
Blablaté par Harko
n°2043190
gatsu35
Blablaté par Harko
Posté le 19-12-2010 à 23:44:18  profilanswer
 

Code :
  1. var imagesPath = "images/photos/";
  2. var slideShow = function(imageId, images) {
  3. var _this = this;
  4. this.image = document.getElementById(imageId);
  5. this.images = images;
  6. var imageIndex=0;
  7. function change() {
  8.  _this.image.src = imagesPath + _this.images[imageIndex];
  9.  imageIndex = imageIndex>=_this.images.length-1 ? 0 : imageIndex+1;
  10.  setTimeout(change,2000);
  11. }
  12. change();
  13. }
  14. window.onload = function() {
  15. new slideShow("image1", ["12 APO.jpg", "caverne V2.jpg", "IMG_5385.jpg"]);
  16. new slideShow("image2", ["IMG_6328.jpg", "IMG_6339.jpg", "IMG_6350.jpg"]);
  17. }


 
et bien sur tu créés 2 images avec un id différent :  

Code :
  1. <image id="image1" src="......"/>
  2. <image id="image2" src="......"/>


---------------
Blablaté par Harko

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

  conflit avec deux javascript

 

Sujets relatifs
cours en langage C/C++ et javascriptProgrammation javascript Acrobat X pro pour feuille de perso cthulhu
[Résolu] Javascript qui test checkbox cochéescript javascript
Conflit javascript[JS ] Conflit ***.js avec prototype.js
[HTML/CSS/Javascript] conflit body onload / window.onloadConflit javascript ?
conflit javascript 
Plus de sujets relatifs à : conflit avec deux javascript


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