From 1109132f09d75da9a28b649c7677bb6ce07c40c0 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:45 -0500 Subject: initial commit --- files/es/web/api/history/index.html | 86 ++++++++++++++++++++++++ files/es/web/api/history/length/index.html | 56 ++++++++++++++++ files/es/web/api/history/pushstate/index.html | 96 +++++++++++++++++++++++++++ 3 files changed, 238 insertions(+) create mode 100644 files/es/web/api/history/index.html create mode 100644 files/es/web/api/history/length/index.html create mode 100644 files/es/web/api/history/pushstate/index.html (limited to 'files/es/web/api/history') diff --git a/files/es/web/api/history/index.html b/files/es/web/api/history/index.html new file mode 100644 index 0000000000..03bcb13185 --- /dev/null +++ b/files/es/web/api/history/index.html @@ -0,0 +1,86 @@ +--- +title: History +slug: Web/API/History +tags: + - API + - HTML DOM + - History API + - Interface + - NeedsTranslation + - TopicStub + - Web +translation_of: Web/API/History +--- +
{{ APIRef("History API") }}
+ +

The History interface allows manipulation of the browser session history, that is the pages visited in the tab or frame that the current page is loaded in.

+ +

Properties

+ +

The History interface doesn't inherit any property.

+ +
+
{{domxref("History.length","length")}} {{readOnlyInline}}
+
Returns an Integer representing the number of elements in the session history, including the currently loaded page. For example, for a page loaded in a new tab this property returns 1.
+
{{domxref("History.scrollRestoration","scrollRestoration")}}
+
Allows web applications to explicitly set default scroll restoration behavior on history navigation. This property can be either auto or manual.
+
{{domxref("History.state","state")}} {{readOnlyInline}}
+
Returns an any value representing the state at the top of the history stack. This is a way to look at the state without having to wait for a {{event("popstate")}} event.
+
+ +

Methods

+ +

The History interface doesn't inherit any methods.

+ +
+
{{domxref("History.back","back()")}}
+
This asynchronous method goes to the previous page in session history, the same action as when the user clicks the browser's Back button. Equivalent to history.go(-1). +
Calling this method to go back beyond the first page in the session history has no effect and doesn't raise an exception.
+
+
{{domxref("History.forward","forward()")}}
+
This asynchronous method goes to the next page in session history, the same action as when the user clicks the browser's Forward button; this is equivalent to history.go(1). +
Calling this method to go forward beyond the most recent page in the session history has no effect and doesn't raise an exception.
+
+
{{domxref("History.go","go()")}}
+
Asynchronously loads a page from the session history, identified by its relative location to the current page, for example -1 for the previous page or 1 for the next page. If you specify an out-of-bounds value (for instance, specifying -1 when there are no previously-visited pages in the session history), this method silently has no effect. Calling go() without parameters or a value of 0 reloads the current page. Internet Explorer lets you specify a string, instead of an integer, to go to a specific URL in the history list.
+
{{domxref("History.pushState","pushState()")}}
+
Pushes the given data onto the session history stack with the specified title (and, if provided, URL). The data is treated as opaque by the DOM; you may specify any JavaScript object that can be serialized.  Note that all browsers but Safari currently ignore the title parameter. For more information, see Working with the History API.
+
{{domxref("History.replaceState","replaceState()")}}
+
Updates the most recent entry on the history stack to have the specified data, title, and, if provided, URL. The data is treated as opaque by the DOM; you may specify any JavaScript object that can be serialized.  Note that all browsers but Safari currently ignore the title parameter. For more information, see Working with the History API.
+
+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', "browsers.html#the-history-interface", "History")}}{{Spec2('HTML WHATWG')}}Adds the scrollRestoration attribute.
{{SpecName('HTML5 W3C', "browsers.html#the-history-interface", "History")}}{{Spec2('HTML5 W3C')}}Initial definition.
+ +

Browser compatibility

+ + + +

{{Compat("api.History")}}

+ +

See also

+ + diff --git a/files/es/web/api/history/length/index.html b/files/es/web/api/history/length/index.html new file mode 100644 index 0000000000..f8d8bd65ba --- /dev/null +++ b/files/es/web/api/history/length/index.html @@ -0,0 +1,56 @@ +--- +title: History.length +slug: Web/API/History/length +tags: + - API + - DOM HTML + - Historial de navegación + - History + - Lectura + - Navegador + - Propiedad + - historial +translation_of: Web/API/History/length +--- +
{{APIRef("History API")}}
+ +

La propiedad de sólo lectura History.length retorna un entero representando el número de elementos en el historial de la sesión, incluyendo la página cargada actualmente. Por ejemplo, para una página cargada en una nueva pestaña esta propiedad retorna 1.

+ +

Sintaxis

+ +
const length = history.length
+
+ +

Especificaciones

+ + + + + + + + + + + + + + + + + + + +
EspecificaciónEstadoComentario
{{SpecName('HTML WHATWG', "history.html#dom-history-length", "History.length")}}{{Spec2('HTML WHATWG')}}Sin cambios desde {{SpecName("HTML5 W3C")}}.
{{SpecName('HTML5 W3C', "browsers.html#dom-history-length", "History.length")}}{{Spec2('HTML5 W3C')}}Definición Inicial.
+ +

Compatibilidad de Navegadores

+ + + +

{{Compat("api.History.length")}}

+ +

Mira también

+ + diff --git a/files/es/web/api/history/pushstate/index.html b/files/es/web/api/history/pushstate/index.html new file mode 100644 index 0000000000..29de4cf521 --- /dev/null +++ b/files/es/web/api/history/pushstate/index.html @@ -0,0 +1,96 @@ +--- +title: History.pushState() +slug: Web/API/History/pushState +tags: + - API + - DOM HTML + - Historial de navegación + - History + - History API + - Navegador + - Sesion + - URL + - Web + - historial + - pushState +translation_of: Web/API/History/pushState +--- +
{{APIRef("History API")}}
+ +

En un documento HTML, el método history.pushState() anexa un registro en la sesión de historial del navegador.

+ +

Sintaxis

+ +
history.pushState(state, title, [url])
+ +

Parámetros

+ +
+
state
+
El objeto state es un objeto de JavaScript asociado al nuevo registro en el historial creado por pushState(). Cuando el usuario navega al nuevo registro, un evento {{event("popstate")}} es accionado, y la propiedad state del evento contiene una copia del objeto state del registro en el historial.
+
El objeto state puede ser cualquier cosa que pueda ser serializada. Porque Firefox guarda los objetos  state en el disco del usuario para que así puedan ser restaurados luego de que el usuario reinicia el navegador, se impone un límite de 640k caracteres en la representación serializada de un objeto state. Si pasas un objeto state con una representación serializada más grande que lo mencionado, a pushState(), el método arrojará una excepción. Si necesitas más espacio que el mencionado, es recomendable que uses {{domxref("Window.sessionStorage", "sessionStorage")}} y/o {{domxref("Window.localStorage", "localStorage")}}.
+
title
+
La mayoría de los navegadores ignoran este parámetro, sin embargo, podrían usarlo en el futuro. Pasar una cadena de texto vacía aquí, debería ser seguro contra futuros cambios en el método. Alternativamente, podrías pasar un título corto por el estado al cual te estás moviendo. Si necesitas que el título sea modificado, puedes usar {{domxref("Document.title", "document.title")}}.
+
url {{optional_inline}}
+
La URL del nuevo registro en el historial, se define en este parámetro. Es importante destacar que el navegador no intentará cargar esta URL luego de una llamada a pushState(), pero podría intentar cargar esta URL luego, por ejemplo, luego de que el usuario reinicie el navegador. La nueva URL no necesita ser absoluta; puede ser relativa a la URL actual. La nueva URL debe tener el mismo {{glossary("origin")}} que la URL actual; de otra manera, pushState() arrojará una excepción. Si este parámetro no es especificado, por defecto se usa la URL del documento actual.
+
+ +

Descripción

+ +

En cierto sentido, llamar a pushState() es similar a window.location = "#foo", ambos crearán y activarán un nuevo registro en el historial asociado al documento actual. Pero pushState() tiene unas ventajas adicionales:

+ + + +

Cabe destacar que pushState() nunca hace que el evento {{event("hashchange")}} sea accionado, incluso si la nueva URL difiere de la URL antigua sólo en su hash.

+ +

En otros documentos, crea u nelemento con una URI null.

+ +

Ejemplos

+ +

Esto crea un nuevo registro en el historial del navegador, estableciendo state, title, y url.

+ +

JavaScript

+ +
const state = { 'page_id': 1, 'user_id': 5 }
+const title = ''
+const url = 'hello-world.html'
+
+history.pushState(state, title, url)
+ +

Especificaciones

+ + + + + + + + + + + + + + + + + + + +
EspecificaciónEstadoComentario
{{SpecName('HTML WHATWG', "history.html#dom-history-pushstate", "History.pushState()")}}{{Spec2('HTML WHATWG')}}Ningún cambio desde {{SpecName("HTML5 W3C")}}.
{{SpecName('HTML5 W3C', "history.html#dom-history-pushstate", "History.pushState()")}}{{Spec2('HTML5 W3C')}}Definición Inicial.
+ +

Compatibilidad en Navegadores

+ + + +

{{Compat("api.History.pushState")}}

+ +

Mira también

+ + -- cgit v1.2.3-54-g00ecf