Comment rediriger l'utilisateur vers une autre URL lors du chargement de Windows
marque22
J'ai le code ci-dessous mais cela ne fonctionne pas, je ne sais pas ce que je fais mal.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
if(window.innerWidth <= 800 && window.innerHeight <= 600) {
window.location = "http://www.youtube.com";
} else {
window.location = "http://www.google.com";
}
</script>
</body>
</html>
Quelqu'un peut-il m'aider, s'il-vous-plaît?
Merci d'avance.
Vitalii Chmovzh
Modifiez légèrement votre code en :
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script>
if(window.innerWidth <= 800 && window.innerHeight <= 600) {
location.href = "http://www.youtube.com";
} else {
location.href = "http://www.google.com";
}
</script>
</body>
</html>
Utilisez location.href au lieu de window.location .