diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:52 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:52 -0500 |
commit | 074785cea106179cb3305637055ab0a009ca74f2 (patch) | |
tree | e6ae371cccd642aa2b67f39752a2cdf1fd4eb040 /files/pt-br/web/api/windoweventhandlers | |
parent | da78a9e329e272dedb2400b79a3bdeebff387d47 (diff) | |
download | translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.gz translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.bz2 translated-content-074785cea106179cb3305637055ab0a009ca74f2.zip |
initial commit
Diffstat (limited to 'files/pt-br/web/api/windoweventhandlers')
4 files changed, 509 insertions, 0 deletions
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 +--- +<div>{{APIRef("HTML DOM")}}</div> + +<p><strong><code>WindowEventHandlers</code></strong> 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.</p> + +<p><code>WindowEventHandlers</code> não é uma interface e nenhum objeto desse tipo pode ser criado.</p> + +<h2 id="Properties">Properties</h2> + +<p><em>As propriedades de evento, no formulário <code>onXYZ</code>, são definidas no {{domxref("WindowEventHandlers")}}, e implementadas por {{domxref("Window")}}, e {{domxref("WorkerGlobalScope")}} para desenvolvedores web.</em></p> + +<dl> + <dt>{{domxref("WindowEventHandlers.onafterprint")}}</dt> + <dd>É uma {{domxref("EventHandler")}} representando o código que será chamando quando o evento {{event("afterprint")}} é invocado.</dd> + <dt>{{domxref("WindowEventHandlers.onbeforeprint")}}</dt> + <dd>É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("beforeprint")}} é invocado.</dd> + <dt>{{domxref("WindowEventHandlers.onbeforeunload")}}</dt> + <dd>É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("beforeunload")}} é invocado.</dd> + <dt>{{domxref("WindowEventHandlers.onhashchange")}}</dt> + <dd>É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("hashchange")}} é invocado.</dd> + <dt>{{domxref("WindowEventHandlers.onlanguagechange")}} {{experimental_inline}}</dt> + <dd>É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("languagechange")}} é invocado.</dd> + <dt>{{domxref("WindowEventHandlers.onmessage")}}</dt> + <dd>É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("message")}} é invocado.</dd> + <dt>{{domxref("WindowEventHandlers.onoffline")}}</dt> + <dd>É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("offline")}} é invocado.</dd> + <dt>{{domxref("WindowEventHandlers.ononline")}}</dt> + <dd>É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("online")}} é invocado.</dd> + <dt>{{domxref("WindowEventHandlers.onpagehide")}}</dt> + <dd>É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("pagehide")}} é invocado.</dd> + <dt>{{domxref("WindowEventHandlers.onpageshow")}}</dt> + <dd>É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("pageshow")}} é invocado.</dd> + <dt>{{domxref("WindowEventHandlers.onpopstate")}}</dt> + <dd>É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("popstate")}} é invocado.</dd> + <dt>{{domxref("WindowEventHandlers.onresize")}}</dt> + <dd>É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("resize")}} é invocado.</dd> + <dt>{{domxref("WindowEventHandlers.onstorage")}}</dt> + <dd>É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("storage")}} é invocado.</dd> + <dt>{{domxref("WindowEventHandlers.onunload")}}</dt> + <dd>É um {{domxref("EventHandler")}} representando o código que será chamado quando o evento {{event("unload")}} é invocado.</dd> +</dl> + +<h2 id="Métodos">Métodos</h2> + +<p><em>Esta interface não define métodos.</em></p> + +<h2 id="Specifications">Specifications</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('HTML WHATWG', '#windoweventhandlers', 'GlobalEventHandlers')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td>No change since the latest snapshot, {{SpecName("HTML5.1")}}.</td> + </tr> + <tr> + <td>{{SpecName('HTML5.1', '#windoweventhandlers', 'GlobalEventHandlers')}}</td> + <td>{{Spec2('HTML5.1')}}</td> + <td>Snapshot of {{SpecName("HTML WHATWG")}}. Added <code>onlanguage</code> since the {{SpecName("HTML 5")}} snapshot.</td> + </tr> + <tr> + <td>{{SpecName("HTML5 W3C", "#windoweventhandlers", "GlobalEventHandlers")}}</td> + <td>{{Spec2('HTML5 W3C')}}</td> + <td>Snapshot of {{SpecName("HTML WHATWG")}}. Creation of <code>WindowEventHandlers</code> (properties where on the target before it).</td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Firefox (Gecko)</th> + <th>Chrome</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + <tr> + <td><code>onhashchange</code></td> + <td>{{CompatGeckoDesktop(1.9.2)}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + <tr> + <td><code>onlanguage</code>{{experimental_inline}}</td> + <td>{{CompatGeckoDesktop(32)}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + <tr> + <td><code>onstorage</code></td> + <td>{{CompatNo}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Firefox Mobile (Gecko)</th> + <th>Android</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatVersionUnknown}}</td> + <td rowspan="1">{{CompatUnknown}}</td> + <td rowspan="1">{{CompatUnknown}}</td> + <td rowspan="1">{{CompatUnknown}}</td> + <td rowspan="1">{{CompatUnknown}}</td> + </tr> + <tr> + <td><code>onhashchange</code></td> + <td>{{CompatGeckoMobile(1.9.2)}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + <tr> + <td><code>onlanguage</code>{{experimental_inline}}</td> + <td>{{CompatGeckoMobile(32)}}</td> + <td rowspan="1">{{CompatUnknown}}</td> + <td rowspan="1">{{CompatUnknown}}</td> + <td rowspan="1">{{CompatUnknown}}</td> + <td rowspan="1">{{CompatUnknown}}</td> + </tr> + <tr> + <td><code>onstorage</code></td> + <td>{{CompatNo}}</td> + <td rowspan="1">{{CompatUnknown}}</td> + <td rowspan="1">{{CompatUnknown}}</td> + <td rowspan="1">{{CompatUnknown}}</td> + <td rowspan="1">{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="Veja_também">Veja também</h2> + +<ul> + <li>{{domxref("Window")}} e {{domxref("WorkerGlobalScope")}}</li> +</ul> 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 +--- +<div> +<div>{{APIRef("HTML DOM")}}</div> +</div> + +<p>O evento <strong>hashchange </strong>é disparado quando a <em>hash</em> da <em>window</em> muda. (ver {{domxref("Window.location", "location.hash")}}).</p> + +<h2 id="Sintaxe">Sintaxe</h2> + +<pre class="syntaxbox">window.onhashchange = funcRef; +</pre> + +<p><strong>ou</strong></p> + +<pre class="syntaxbox"><body onhashchange="funcRef();"> +</pre> + +<p><strong>ou</strong></p> + +<pre class="syntaxbox">window.addEventListener("hashchange", funcRef, false); +</pre> + +<h3 id="Parâmetros">Parâmetros</h3> + +<dl> + <dt><code>funcRef</code></dt> + <dd>Referência a uma função</dd> +</dl> + +<h2 id="Exemplo">Exemplo</h2> + +<pre class="brush:js">if ("onhashchange" in window) { + alert("O browser têm suporte ao evento hashchange!"); +} + +function locationHashChanged() { + if (location.hash === "#algointeressante") { + algoInteressante(); + } +} + +window.onhashchange = locationHashChanged; +</pre> + +<h2 id="O_evento_hashchange">O evento hashchange</h2> + +<p>O evento hashchange disparado possui os seguintes campos</p> + +<table class="standard-table"> + <tbody> + <tr> + <td class="header">Campo</td> + <td class="header">Tipo</td> + <td class="header">Descrição</td> + </tr> + <tr> + <td><code>newURL</code> {{gecko_minversion_inline("6.0")}}</td> + <td><code>DOMString</code></td> + <td>A nova URL para a qual a janela está navegando.</td> + </tr> + <tr> + <td><code>oldURL</code> {{gecko_minversion_inline("6.0")}}</td> + <td><code>DOMString</code></td> + <td>A antiga URL da qual a janela veio.</td> + </tr> + </tbody> +</table> + +<h2 id="Especificações">Especificações</h2> + +<table class="standard-table"> + <thead> + <tr> + <th scope="col">Especificação</th> + <th scope="col">Status</th> + <th scope="col">Comentário</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName('HTML WHATWG', '#windoweventhandlers', 'GlobalEventHandlers')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName('HTML5.1', '#windoweventhandlers', 'GlobalEventHandlers')}}</td> + <td>{{Spec2('HTML5.1')}}</td> + <td> </td> + </tr> + <tr> + <td>{{SpecName("HTML5 W3C", "#windoweventhandlers", "GlobalEventHandlers")}}</td> + <td>{{Spec2('HTML5 W3C')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Browser_compatibility" name="Browser_compatibility">Compatibilidade dos Browsers</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Suporte Básico</td> + <td>5.0</td> + <td>{{CompatGeckoDesktop("1.9.2")}}</td> + <td> + <p>8.0</p> + + <p><span style="font-size: 11.9999990463257px; line-height: 20px;">atributos </span><code style="font-size: 14px;">oldURL</code>/<code style="font-size: 14px;">newURL</code> não são suportados.</p> + </td> + <td>10.6</td> + <td>5.0</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Suporte Básico</td> + <td>2.2</td> + <td>{{CompatGeckoMobile("1.9.2")}}</td> + <td>9.0</td> + <td>11.0</td> + <td>5.0</td> + </tr> + </tbody> +</table> +</div> + +<ul> + <li><a href="/en-US/docs/DOM/Manipulating_the_browser_history" title="DOM/Manipulating the browser history">Manipulando o histórico do browser</a>, métodos <a href="/en-US/docs/DOM/window.history" title="DOM/window.history">history.pushState() e history.replaceState()</a>, evento <a href="/en-US/docs/DOM/window.onpopstate" title="DOM/window.onpopstate">popstate</a>.</li> +</ul> 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 +--- +<div>{{APIRef}} {{gecko_minversion_header("2")}}</div> + +<h2 id="Summary" name="Summary">Sumário</h2> + +<p>Um evento manipulador para um evento <code>popstate</code> na janela</p> + +<p>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 <code>history.pushState()</code> ou for afetado por um chamada <code>history.replaceState()</code>, o estado do evento <code>popstate </code>contém uma cópia do histórico do estado de entrada do objeto.</p> + +<p>Note que apenas chamando <code>history.pushState()</code> ou <code>history.replaceState() </code>não irá desencadear um evento<code> popstate. </code>O evento <code>popstate </code>é apenas desencadeado por uma ação do navegador com clicar em um botão de voltar (ou chamar <code>history.back() </code>em JavaScript). E o evento é apenas desencadeado quando o usuário navega entre dois históricos de entrada do mesmo documento.<br> + <br> + Navegadores tendem a lidar com o evento <code>popstate </code>diferente no carregamento da página. Chrome (anterior versão 34) e Safari sempre emite um evento <code>popstate</code> no carregamento da página, mas Firefox não.</p> + +<h2 id="Syntax" name="Syntax">Sintaxe</h2> + +<pre class="syntaxbox">window.onpopstate = <var>funcRef</var>; +</pre> + +<ul> + <li><var>funcRef</var> é uma função de manipulador.</li> +</ul> + +<h2 id="The_popstate_event" name="The_popstate_event">O evento popstate</h2> + +<p>Como um exemplo, a página no <code><var>http://example.com/example.html</var></code> roda o seguinte código que vai gerar alertas conforme indicado:</p> + +<pre class="brush:js">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} +</pre> + +<div id="gt-src-tools"> +<div dir="ltr" style="zoom: 1;"><span id="result_box" lang="pt"><span class="hps">Observe que mesmo que</span> <span class="hps">a entrada do histórico</span> <span class="hps">inicial (para </span></span><code><var>http://example.com/example.html</var></code><span lang="pt"><span class="hps">) </span></span>não tem objeto estado associado com ele, um evento <code>popstate</code> é ainda disparado quando nós ativamos essa entrada depois da segunda chamada do <code>history.back()</code>.<br> +<br> + </div> +</div> + +<h2 id="Specification" name="Specification">Especificação</h2> + +<ul> + <li><a href="http://www.whatwg.org/specs/web-apps/current-work/#handler-window-onpopstate">HTML5 popstate event</a></li> +</ul> + +<h2 id="See_also" name="See_also">Veja também</h2> + +<ul> + <li>{{domxref("window.history")}}</li> + <li><a href="/en-US/docs/Web/Guide/DOM/Manipulating_the_browser_history">Manipulating the browser history</a></li> + <li><a href="/en-US/docs/Web/Guide/DOM/Manipulating_the_browser_history/Example">Ajax navigation example</a></li> +</ul> 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 +--- +<div class="syntaxbox">{{ ApiRef() }}</div> + +<p>A propriedade <strong><code>WindowEventHandlers.onstorage</code></strong> 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.)</p> + +<h2 id="Syntax" name="Syntax">Sintaxe</h2> + +<pre class="syntaxbox"><em>windowObj</em>.onstorage = function() { ... };</pre> + +<h2 id="Specification" name="Specification">Exemplos</h2> + +<pre class="brush: js">window.onstorage = function(e) { + console.log('The ' + e.key + ' key has been changed from ' + e.oldValue + ' to ' + e.newValue + '.'); +};</pre> + +<h2 id="Especificações">Especificações</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Especificação</th> + <th scope="col">Status</th> + <th scope="col">Comentário</th> + </tr> + <tr> + <td>{{SpecName('HTML WHATWG','webappapis.html#handler-window-onstorage','onstorage')}}</td> + <td>{{Spec2('HTML WHATWG')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilidade_entre_navegadores">Compatibilidade entre navegadores</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Característica</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari (WebKit)</th> + </tr> + <tr> + <td>Suporte básico</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoDesktop(45)}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile" style="line-height: 19.0909080505371px;"> +<table class="compat-table"> + <tbody> + <tr> + <th>Característica</th> + <th>Android</th> + <th>Android Webview</th> + <th>Edge</th> + <th>Firefox Mobile (Gecko)</th> + <th>Firefox OS</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + <th>Chrome para Android</th> + </tr> + <tr> + <td>Suporte básico</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatGeckoMobile(45)}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> |