Javascript1.2 - background

Marc -  
 mmilian -
Bonjour et merci de votre attention.
J'ai un problème de fond :)

Je souhaite:
- tester la résolution d'écran
- faire afficher l'image de fond en fonction de la résolution

Pour ce faire voici le code que j'utilise mais il ne marche pas!
Si vous comprenez mon erreur ou si vous avez une solution de contournement astucieuse je suis tout à votre écoute...

Marc<html>
<head>
<title>Untitled Document</title>
<SCRIPT LANGUAGE="JavaScript1.2">
</SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" backgroung="javascript:(screen.width==800)?document.write("fond_acc.jpg"):document.write("fond_acc_1024.jpg")" text="#000000">
<SCRIPT LANGUAGE="JavaScript1.2">
<!-- debut du script

if (screen.width==800)
alert("vous êtes en 800x600");

else if (screen.width >=1024)
alert("vous êtes en 1024x768 ou plus");

// Fin du script -->


</body>
</html>
A voir également:

1 réponse

okabeche Messages postés 8 Statut Membre 4
 
Voilà ta réponse.

<html>
<head>
<title>Untitled Document</title>

<SCRIPT LANGUAGE="JavaScript">
<!-- debut du script
function Bckgrnd()
{
if (screen.width==800)
{
alert('vous êtes en 800x600');
document.body.background='2.jpg';
}
else if (screen.width >=1024)
{
alert('vous êtes en 1024x768 ou plus');
document.body.background='1.jpg';
}
}
// Fin du script -->
</SCRIPT>
</head>

<body onLoad="Bckgrnd()" text="#000000">
<H1>Hello</H1>
</body>
</html>

Bon courage !
0
mmilian
 
Merci bien!
Où puis-je trouver une liste exhaustive des propriétés et méthodes des objets document, window, etc...
@+
Marc
0