History back()Método
Objeto History
Definición y uso
El método back() carga la URL anterior en la lista de historial (si existe).
El efecto de llamar a este método es equivalente a hacer clic en el botón atrás o llamar a history.go(-1).
Sintaxis
history.back()
Soporte del navegador
![]()
![]()
![]()
![]()
![]()
Todos los navegadores principales admiten el método back()
Ejemplo
Ejemplo
Crea un botón de retroceso en una página:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (example.com)</title>
<script>
function goBack(){
window.history.back()
}
</script>
</head>
<body>
<input type="button" value="Volver" onclick="goBack()">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial de novatos (example.com)</title>
<script>
function goBack(){
window.history.back()
}
</script>
</head>
<body>
<input type="button" value="Volver" onclick="goBack()">
</body>
</html>
El resultado del ejemplo anterior:
Pruébalo »
Objeto History Otras extensiones