From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- files/pt-br/web/api/windoweventhandlers/index.html | 189 +++++++++++++++++++++ .../windoweventhandlers/onhashchange/index.html | 158 +++++++++++++++++ .../api/windoweventhandlers/onpopstate/index.html | 61 +++++++ .../api/windoweventhandlers/onstorage/index.html | 101 +++++++++++ 4 files changed, 509 insertions(+) create mode 100644 files/pt-br/web/api/windoweventhandlers/index.html create mode 100644 files/pt-br/web/api/windoweventhandlers/onhashchange/index.html create mode 100644 files/pt-br/web/api/windoweventhandlers/onpopstate/index.html create mode 100644 files/pt-br/web/api/windoweventhandlers/onstorage/index.html (limited to 'files/pt-br/web/api/windoweventhandlers') diff --git a/files/pt-br/web/api/windoweventhandlers/index.html b/files/pt-br/web/api/windoweventhandlers/index.html new file mode 100644 index 0000000000..5eff621233 --- /dev/null +++ b/files/pt-br/web/api/windoweventhandlers/index.html @@ -0,0 +1,189 @@ +--- +title: WindowEventHandlers +slug: Web/API/WindowEventHandlers +tags: + - API + - HTML-DOM + - Interface + - NeedsTranslation + - Reference + - TopicStub +translation_of: Web/API/WindowEventHandlers +--- +
{{APIRef("HTML DOM")}}
+ +

WindowEventHandlers descreve os manipuladores de eventos comuns a várias interfaces como {{domxref("Window")}}, ou {{domxref("HTMLBodyElement")}} e  {{domxref("HTMLFrameSetElement")}}. Cada uma dessas interfaces podendo implementar manipuladores de eventos específicos adicionais.

+ +

WindowEventHandlers não é uma interface e nenhum objeto desse tipo pode ser criado.

+ +

Properties

+ +

As propriedades de evento, no formulário onXYZ, são definidas no {{domxref("WindowEventHandlers")}}, e implementadas por {{domxref("Window")}}, e {{domxref("WorkerGlobalScope")}} para desenvolvedores web.

+ +
+
{{domxref("WindowEventHandlers.onafterprint")}}
+
É uma {{domxref("EventHandler")}} representando o código que será chamando quando o evento {{event("afterprint")}} é invocado.
+
{{domxref("WindowEventHandlers.onbeforeprint")}}
+
É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("beforeprint")}} é invocado.
+
{{domxref("WindowEventHandlers.onbeforeunload")}}
+
É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento  {{event("beforeunload")}} é invocado.
+
{{domxref("WindowEventHandlers.onhashchange")}}
+
É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("hashchange")}} é invocado.
+
{{domxref("WindowEventHandlers.onlanguagechange")}} {{experimental_inline}}
+
É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("languagechange")}} é invocado.
+
{{domxref("WindowEventHandlers.onmessage")}}
+
É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento  {{event("message")}} é invocado.
+
{{domxref("WindowEventHandlers.onoffline")}}
+
É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento  {{event("offline")}} é invocado.
+
{{domxref("WindowEventHandlers.ononline")}}
+
É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento  {{event("online")}} é invocado.
+
{{domxref("WindowEventHandlers.onpagehide")}}
+
É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("pagehide")}} é invocado.
+
{{domxref("WindowEventHandlers.onpageshow")}}
+
É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("pageshow")}} é invocado.
+
{{domxref("WindowEventHandlers.onpopstate")}}
+
É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("popstate")}} é invocado.
+
{{domxref("WindowEventHandlers.onresize")}}
+
É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("resize")}} é invocado.
+
{{domxref("WindowEventHandlers.onstorage")}}
+
É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("storage")}} é invocado.
+
{{domxref("WindowEventHandlers.onunload")}}
+
É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("unload")}} é invocado.
+
+ +

Métodos

+ +

Esta interface não define métodos.

+ +

Specifications

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('HTML WHATWG', '#windoweventhandlers', 'GlobalEventHandlers')}}{{Spec2('HTML WHATWG')}}No change since the latest snapshot, {{SpecName("HTML5.1")}}.
{{SpecName('HTML5.1', '#windoweventhandlers', 'GlobalEventHandlers')}}{{Spec2('HTML5.1')}}Snapshot of {{SpecName("HTML WHATWG")}}. Added onlanguage since the {{SpecName("HTML 5")}} snapshot.
{{SpecName("HTML5 W3C", "#windoweventhandlers", "GlobalEventHandlers")}}{{Spec2('HTML5 W3C')}}Snapshot of {{SpecName("HTML WHATWG")}}. Creation of WindowEventHandlers (properties where on the target before it).
+ +

Browser compatibility

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureFirefox (Gecko)ChromeInternet ExplorerOperaSafari
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
onhashchange{{CompatGeckoDesktop(1.9.2)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
onlanguage{{experimental_inline}}{{CompatGeckoDesktop(32)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
onstorage{{CompatNo}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureFirefox Mobile (Gecko)AndroidIE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
onhashchange{{CompatGeckoMobile(1.9.2)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
onlanguage{{experimental_inline}}{{CompatGeckoMobile(32)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
onstorage{{CompatNo}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +

Veja também

+ + diff --git a/files/pt-br/web/api/windoweventhandlers/onhashchange/index.html b/files/pt-br/web/api/windoweventhandlers/onhashchange/index.html new file mode 100644 index 0000000000..5cca998fbe --- /dev/null +++ b/files/pt-br/web/api/windoweventhandlers/onhashchange/index.html @@ -0,0 +1,158 @@ +--- +title: WindowEventHandlers.onhashchange +slug: Web/API/WindowEventHandlers/onhashchange +translation_of: Web/API/WindowEventHandlers/onhashchange +--- +
+
{{APIRef("HTML DOM")}}
+
+ +

O evento hashchange é disparado quando a hash da window muda. (ver {{domxref("Window.location", "location.hash")}}).

+ +

Sintaxe

+ +
window.onhashchange = funcRef;
+
+ +

ou

+ +
<body onhashchange="funcRef();">
+
+ +

ou

+ +
window.addEventListener("hashchange", funcRef, false);
+
+ +

Parâmetros

+ +
+
funcRef
+
Referência a uma função
+
+ +

Exemplo

+ +
if ("onhashchange" in window) {
+    alert("O browser têm suporte ao evento hashchange!");
+}
+
+function locationHashChanged() {
+    if (location.hash === "#algointeressante") {
+        algoInteressante();
+    }
+}
+
+window.onhashchange = locationHashChanged;
+
+ +

O evento hashchange

+ +

O evento hashchange disparado possui os seguintes campos

+ + + + + + + + + + + + + + + + + + + +
CampoTipoDescrição
newURL {{gecko_minversion_inline("6.0")}}DOMStringA nova URL para a qual a janela está navegando.
oldURL {{gecko_minversion_inline("6.0")}}DOMStringA antiga URL da qual a janela veio.
+ +

Especificações

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
EspecificaçãoStatusComentário
{{SpecName('HTML WHATWG', '#windoweventhandlers', 'GlobalEventHandlers')}}{{Spec2('HTML WHATWG')}} 
{{SpecName('HTML5.1', '#windoweventhandlers', 'GlobalEventHandlers')}}{{Spec2('HTML5.1')}} 
{{SpecName("HTML5 W3C", "#windoweventhandlers", "GlobalEventHandlers")}}{{Spec2('HTML5 W3C')}} 
+ +

Compatibilidade dos Browsers

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
Suporte Básico5.0{{CompatGeckoDesktop("1.9.2")}} +

8.0

+ +

atributos oldURL/newURL não são suportados.

+
10.65.0
+
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Suporte Básico2.2{{CompatGeckoMobile("1.9.2")}}9.011.05.0
+
+ + diff --git a/files/pt-br/web/api/windoweventhandlers/onpopstate/index.html b/files/pt-br/web/api/windoweventhandlers/onpopstate/index.html new file mode 100644 index 0000000000..78bfa8fdc1 --- /dev/null +++ b/files/pt-br/web/api/windoweventhandlers/onpopstate/index.html @@ -0,0 +1,61 @@ +--- +title: WindowEventHandlers.onpopstate +slug: Web/API/WindowEventHandlers/onpopstate +translation_of: Web/API/WindowEventHandlers/onpopstate +--- +
{{APIRef}} {{gecko_minversion_header("2")}}
+ +

Sumário

+ +

Um evento manipulador para um evento popstate na janela

+ +

Um evento popstate é disparado para a janela toda vez que o histórico de atividades mudar entre dois históricos de entradas para o mesmo documento. Se o histórico de entrada a ser ativo for criado por uma chamada para history.pushState() ou for afetado por um chamada history.replaceState(), o estado do evento popstate contém uma cópia do histórico do estado de entrada do objeto.

+ +

Note que apenas chamando history.pushState() ou history.replaceState() não irá desencadear um evento popstate. O evento popstate é apenas desencadeado  por uma ação do navegador com clicar em um botão de voltar (ou chamar history.back() em JavaScript). E o evento é apenas desencadeado quando o usuário navega entre dois históricos de entrada do mesmo documento.
+
+ Navegadores tendem a lidar com o evento popstate diferente no carregamento da página. Chrome (anterior versão 34) e Safari sempre emite um evento popstate no carregamento da página, mas Firefox não.

+ +

Sintaxe

+ +
window.onpopstate = funcRef;
+
+ + + +

O evento popstate

+ +

Como um exemplo, a página no http://example.com/example.html roda o seguinte código que vai gerar alertas conforme indicado:

+ +
window.onpopstate = function(event) {
+  alert("location: " + document.location + ", state: " + JSON.stringify(event.state));
+};
+
+history.pushState({page: 1}, "title 1", "?page=1");
+history.pushState({page: 2}, "title 2", "?page=2");
+history.replaceState({page: 3}, "title 3", "?page=3");
+history.back(); // alertas "location: http://example.com/example.html?page=1, state: {"page":1}"
+history.back(); // alertas "location: http://example.com/example.html, state: null
+history.go(2);  // alertas "location: http://example.com/example.html?page=3, state: {"page":3}
+
+ +
+
Observe que mesmo que a entrada do histórico inicial (para http://example.com/example.html) não tem objeto estado associado com ele, um evento popstate é ainda disparado quando nós ativamos essa entrada depois da segunda chamada do history.back().
+
+
+ +

Especificação

+ + + +

Veja também

+ + diff --git a/files/pt-br/web/api/windoweventhandlers/onstorage/index.html b/files/pt-br/web/api/windoweventhandlers/onstorage/index.html new file mode 100644 index 0000000000..48820c0bfa --- /dev/null +++ b/files/pt-br/web/api/windoweventhandlers/onstorage/index.html @@ -0,0 +1,101 @@ +--- +title: WindowEventHandlers.onstorage +slug: Web/API/WindowEventHandlers/onstorage +tags: + - API + - Armazenamento web + - Propriedade + - Referencia + - WindowEventHandlers +translation_of: Web/API/WindowEventHandlers/onstorage +--- +
{{ ApiRef() }}
+ +

A propriedade WindowEventHandlers.onstorage contém um manipulador de eventos que executa quando o evento {{event("storage")}} dispara. Isto ocorre quando a área de armazenamento é mudada. (ex. um novo item é armazenado.)

+ +

Sintaxe

+ +
windowObj.onstorage = function() { ... };
+ +

Exemplos

+ +
window.onstorage = function(e) {
+  console.log('The ' + e.key + ' key has been changed from ' + e.oldValue + ' to ' + e.newValue + '.');
+};
+ +

Especificações

+ + + + + + + + + + + + + + +
EspecificaçãoStatusComentário
{{SpecName('HTML WHATWG','webappapis.html#handler-window-onstorage','onstorage')}}{{Spec2('HTML WHATWG')}} 
+ +

Compatibilidade entre navegadores

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Suporte básico{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoDesktop(45)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidAndroid WebviewEdgeFirefox Mobile (Gecko)Firefox OSIE MobileOpera MobileSafari MobileChrome para Android
Suporte básico{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile(45)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
-- cgit v1.2.3-54-g00ecf