créer un site


J'ai un gros soucis!

Poster un nouveau sujet sur javascript   Répondre au sujet à javascript:J'ai un gros soucis!    Accueil Forum -> javascript
Voir le sujet précédent :: Voir le sujet suivant  
Auteur Message
Sebe
dreamweaver mioche
dreamweaver mioche
MessageJ'ai un gros soucis! , Posté le: 25-02-2005 19:50

J'ai recopié dans un livre, pour m'exercer au JavaScript, mais il y a un prob que je ne sais pas résoudre même si je sais que c'est un problème avec une syntaxe. Si quelqu'un peut corriger le problème, je serais assez reconnaissant! Voici l'endroit où le problème se situe: (en gras)

Merci



{ // La balise <MARQUEE> est reconnue.
// Vous pouvez donc l'utiliser.

builtInScroll = '<FORM NAME="myForm"><MARQUEE ID=abc DIRECTION=LEFT "
BEHAVIOR=SCROLL SCROLLAMOUNT=2>JavaScript pour les Nuls
</MARQUEE><INPUT "
TYPE="button" VALUE="Début du défilement" NAME="startscroll" "
onClick="document.all.abc.start()"><INPUT TYPE="button" VALUE="Arrêt
du "défilement" NAME="stopscroll"
onClick="document.all.abc.stop()"></FORM>';

// onClick="document.getElementById('abc').stop()"></FORM>';

}
Sebe
dreamweaver mioche
dreamweaver mioche
MessageJ'ai un gros soucis! , Posté le: 27-02-2005 23:18

Le soucis est réparé mais ce code qui devait détecter le navigateur du visiteur ne fonctionnerait que sous IE! Donc aucun intérêt. Je le mets à disposition si quelqu'un veut s'amuser ! ! !


<html>
<head>
<title>"Renifleur" de navigateur</title>

<script language="JavaScript">
function Is()
{ // convertir tous les caractères en minuscules pour simplifier le test
var agt=navigator.userAgent.toLowerCase();

// *** VERSION DU NAVIGATEUR ***
// Note: Avec IE5, on obtient 4, aussi mieux vaut
// utiliser is.ie5up dans ce cas

this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);

this.nav = ((agt.indexOf('mozilla')!=-1) &&
(agt.indexOf('spoofer')==-1) &&
(agt.indexOf('compatible')!=-1) &&
(agt.indexOf('opera')==-1) &&
(agt.indexOf('webtv')==-1));

this.nav2 = (this.nav && (this.major == 2));
this.nav3 = (this.nav && (this.major == 3));
this.nav4 = (this.nav && (this.major == 4));
this.nav4up = (this.nav && (this.major >= 4));
this.navonly = (this.nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)));
this.nav5 = (this.nav && (this.major == 5));

// BUG CONNU : La version bêta de Netscape Navigator 6
// s'identifie sous la référence 5.5.
this.nav6 = ((this.nav) && (this.major == 5) && (this.minor == 5));

this.ie = (agt.indexOf("msie") != -1);
this.ie3 = (this.ie && (this.major < 4));
this.ie4 = (this.ie && (this.major == 4) &&
(agt.indexOf("msie 5.0")==-1) );
this.ie4up = (this.ie && (this.major >= 4));
this.ie5 = (this.ie && (this.major == 4) &&
(agt.indexOf("msie 5.0")!=-1) );
this.ie5up = (this.ie && !this.ie3 && !this.ie4);

// BUG CONNU : Avec AOL4, on obtient false
// si IE3 est le véritable navigateur ou si c'est la première
// fenêtre de navigateur ouverte. Il en résulte que ni is.aol3, ni is aol4
// ne sont fiables à 100%.
this.aol = (agt.indexOf("aol") !=-1);
this.aol3 = (this.aol && this.ie3);
this.aol4 = (this.aol && this.ie4);
this.opera = (agt.indexOf("opera") != -1);
this.webtv = (agt.indexOf("webtv") != -1);

// *** TEST DE LA VERSION DE JAVASCRIPT ***
if (this.nav2 || this.ie3)
this.js = 1.0
else if (this.nav3 || this.opera)
this.js = 1.1
else if ((this.nav4 && (this.minor <= 4.05)) || this.ie4)
this.js = 1.2
else if ((this.nav4 && (this.minor > 4.05)) || this.ie5)
this.js = 1.3
else if (this.nav5)
this.js = 1.4
else if (this.nav6)
this.js = 1.5

// NOTE: Il faudra mettre ce code à jour lorsque de nouvelles versions
// de JavaScript apparaîtront. Pour le moment, nous avons essayé de
// conserver une compatibilité ascendante pour les futures verions de
// Netscape et de Internet Explorer reconnaissent correctement au minimum
// JavaSript JS 1.x Testez toujours la compatibilité avec les
// opérateurs > or >=.


else if (this.nav && (this.major > 6))
this.js = 1.6

// ASTUCE : par prudence, pour la version du JavaScript des autres
// navigateurs, faites le test avec > or >=

else this.js = 0.0;

// *** PLATE-FORME ***
this.win = ( (agt.indexOf("win")!=-1) ||
(agt.indexOf("16bit")!=-1) );

// NOTE : Avec Opera 3.0, la chaîne de caractères userAgent contient
// "Windows 95/NT4" pour tous les systèmes de type Win32, ce qui fait
// que vous ne pouvez pas distinguer l'un de l'autre.

this.win95 = ((agt.indexOf("win95")!=-1) ||
(agt.indexOf("Windows 95")!=-1));

// Est-ce une version 16 bits ?
this.win16 = ((agt.indexOf("win16")!=-1) ||
(agt.indexOf("16bit")!=-1) ||
(agt.indexOf("Windows 3.1")!=-1) ||
(agt.indexOf("Windows 16-bit")!=-1) );

this.win31 = ((agt.indexOf("Windows 3.1")!=-1) ||
(agt.indexOf("win16")!=-1) ||
(agt.indexOf("Windows 16-bit")!=-1) );

// NOTE : Il n'est pas possible de détecter Windows 98 avec certitude :
// - Avec Navigator 4.x et avant d'avoir détecté "Windows" dans userAgent.
// - Avec un client Mercury, dont la version 32 bits renvoie "Win98",
// mais la version 16 bits tournant sous Windows 98
// renvoie toujours "Win95".

this.win98 = ((agt.indexOf("win98")!=-1) ||
(agt.indexOf("Windows 98")!=-1));

this.winnt = ((agt.indexOf("winnt")!=-1) ||
(agt.indexOf("Windows NT")!=-1));

this.win32 = (this.win95 || this.winnt || this.win98
|| ((this.major >=4) && (navigator.platform ==
"Win32")) || (agt.indexOf("win32")!=-1) ||
(agt.indexOf("32bit")!=-1) );

this.os2 = ((agt.indexOf("os/2")!=-1) ||
(navigator.appVersion.indexOf("OS/2")!=-1) ||
(agt.indexOf("ibm-webexplorer")!=-1));

this.mac = (agt.indexOf("mac")!=-1);

this.mac68k = (this.mac && ((agt.indexOf("68k")!=-1) ||
(agt.indexOf("68000")!=-1)));

this.macppc = (this.mac && ((agt.indexOf("ppc")!=-1) ||
(agt.indexOf("powerpc")!=-1)));

this.sun = (agt.indexOf("sunos")!=-1);
this.sun4 = (agt.indexOf("sunos 4")!=-1);
this.sun5 = (agt.indexOf("sunos 5")!=-1);
this.suni86 = (this.sun && (agt.indexOf("i86")!=-1));
this.irix = (agt.indexOf("irix") !=-1); // SGI
this.irix5 = (agt.indexOf("irix 5") !=-1);
this.irix6 = ((agt.indexOf("irix6") !=-1) ||
(agt.indexOf("irix6") !=-1));
this.hpux = (agt.indexOf("hp-ux")!=-1);
this.hpux9 = (this.hpux && (agt.indexOf("09.")!=-1));
this.hpux10 = (this.hpux && (agt.indexOf("10.")!=-1));
this.aix = (agt.indexOf("aix") !=-1); // IBM
this.aix1 = (agt.indexOf("aix 1") !=-1);
this.aix2 = (agt.indexOf("aix 2") !=-1);
this.aix3 = (agt.indexOf("aix 3") !=-1);
this.aix4 = (agt.indexOf("aix 4") !=-1);
this.linux = (agt.indexOf("linux")!=-1);
this.sco = (agt.indexOf("sco")!=-1) ||
(agt.indexOf("unix_sv")!=-1);
this.unixware = (agt.indexOf("unix_systeme_v")!=-1);
this.mpras = (agt.indexOf("ncr")!=-1);
this.reliant = (agt.indexOf("reliantunix")!=-1);
this.dec = ((agt.indexOf("dec")!=-1) ||
(agt.indexOf("osf1")!=-1) ||
(agt.indexOf("dec_alpha")!=-1) ||
(agt.indexOf("alphaserver")!=-1) ||
(agt.indexOf("ultrix")!=-1) ||
(agt.indexOf("alphastation")!=-1));
this.sinix = (agt.indexOf("sinix")!=-1);
this.bsd = (agt.indexOf("bsd")!=-1);
this.unix = ((agt.indexOf("x11")!=-1) || this.sun ||
this.irix || this.hpux ||
this.sco || this.unixware || this.mpras ||
this.reliant || this.dec || this.sinix ||
this.aix || this.linux || this.bsd ||
this.freebsd);
this.vms = ((agt.indexOf("vax")!=-1) ||
(agt.indexOf("openvms")!=-1));

} // Fin de la déclaration de la fonction Is()

var is;
var isIE3Mac = false;

// Cette section concerne spécialement IE3 pour le Mac

if ((navigator.appVersion.indexOf("Mac")!=-1) &&
(navigator.userAgent.indexOf("MSIE")!=-1) &&
(parseInt (navigator.appVersion)==3)) {
isIE3Mac = true;
}
else
{ is = new Is();
var builtInScroll
if (is.ie3up || is.ie4up || is.ie5up)
{ // La balise <MARQUEE> est reconnue.
// Vous pouvez donc l'utiliser.

builtInScroll='<FORM NAME="myForm"><MARQUEE ID="abc" direction="left" behavior="scroll" scrollamount="2">JavaScript pour les Nuls</MARQUEE><INPUT TYPE="button" VALUE="Début du défilement" NAME="startscroll"onClick="document.all.abc.start()"><INPUT TYPE="button" VALUE="Arrêt du défilement" NAME="stopscroll" onClick="document.all.abc.stop()"></FORM>';



// onClick="document.getElementById('abc').stop()"></FORM>';

}

else
{ // Afficher un titre immobile
builtInScroll = '<CENTER><H1>JavaScript pour les Nuls</H1></CENTER>'
}

document.write(builtInScroll)

}
</script>

</head>

<body>



</body>
</html>
Montrer les messages depuis:   
Poster un nouveau sujet sur javascript   Répondre au sujet à javascript:J'ai un gros soucis!    Accueil Forum -> javascript Toutes les heures sont au format GMT + 1 Heure
Page 1 sur 1

 
Sauter vers:  
S'enregistrerS'enregistrer
ProfilProfil
Se connecter pour vérifier ses messages privésSe connecter pour vérifier ses messages privés
RechercherRechercher
Liste des MembresMembres
FAQFAQ
ConnexionConnexion 


© Mentions Légales