Location assign()Méthode
Objet Location
Définition et utilisation
La méthode assign() charge un nouveau document.
Syntaxe
location.assign(URL)
Prise en charge des navigateurs
![]()
![]()
![]()
![]()
![]()
Tous les principaux navigateurs prennent en charge la méthode assign().
Exemple
Exemple
Utilisez assign() pour charger un nouveau document :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function newDoc(){
window.location.assign("http://www.example.com")
}
</script>
</head>
<body>
<input type="button" value="Charger un nouveau document" onclick="newDoc()">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function newDoc(){
window.location.assign("http://www.example.com")
}
</script>
</head>
<body>
<input type="button" value="Charger un nouveau document" onclick="newDoc()">
</body>
</html>
Essayez-le vous-même »
Objet Location Autres extensions