diff options
author | Alexey Pyltsyn <lex61rus@gmail.com> | 2021-10-27 02:31:24 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-27 02:31:24 +0300 |
commit | 980fe00a74a9ad013b945755415ace2e5429c3c2 (patch) | |
tree | a1c6bb4b302e69bfa53eab13e44500eba55d1696 /files/ru/web/api/settimeout | |
parent | 374a039b97a11ee7306539d16aaab27fed66b398 (diff) | |
download | translated-content-980fe00a74a9ad013b945755415ace2e5429c3c2.tar.gz translated-content-980fe00a74a9ad013b945755415ace2e5429c3c2.tar.bz2 translated-content-980fe00a74a9ad013b945755415ace2e5429c3c2.zip |
[RU] Remove notranslate (#2874)
Diffstat (limited to 'files/ru/web/api/settimeout')
-rw-r--r-- | files/ru/web/api/settimeout/index.html | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/files/ru/web/api/settimeout/index.html b/files/ru/web/api/settimeout/index.html index 5c4cb67a3b..6e38955b9f 100644 --- a/files/ru/web/api/settimeout/index.html +++ b/files/ru/web/api/settimeout/index.html @@ -12,7 +12,7 @@ original_slug: Web/API/WindowOrWorkerGlobalScope/setTimeout <h2 id="Syntax">Синтаксис</h2> -<pre class="syntaxbox notranslate"><em>var timeoutID</em> = window.setTimeout(<em>func</em>, [, <em>delay</em>, <em>param1</em>, <em>param2</em>, ...]); +<pre class="syntaxbox"><em>var timeoutID</em> = window.setTimeout(<em>func</em>, [, <em>delay</em>, <em>param1</em>, <em>param2</em>, ...]); <em>var timeoutID</em> = window.setTimeout(<em>code </em>[, <em>delay]</em>); </pre> @@ -35,7 +35,7 @@ original_slug: Web/API/WindowOrWorkerGlobalScope/setTimeout <h3 id="HTML_Content">HTML Content</h3> -<pre class="brush: html notranslate"><p>Live Example</p> +<pre class="brush: html"><p>Live Example</p> <button onclick="delayedAlert();">Show an alert box after two seconds</button> <p></p> <button onclick="clearAlert();">Cancel alert before it happens</button> @@ -43,7 +43,7 @@ original_slug: Web/API/WindowOrWorkerGlobalScope/setTimeout <h3 id="JavaScript_Content">JavaScript Content</h3> -<pre class="brush: js notranslate">var timeoutID; +<pre class="brush: js">var timeoutID; function delayedAlert() { timeoutID = window.setTimeout(slowAlert, 2000); @@ -66,7 +66,7 @@ function clearAlert() { <p>Если вам нужно передать аргумент в вашу callback функцию, но нужно, чтобы это работало в Internet Explorer 9 и ниже, который не поддерживает передачу дополнительных параметров (ни с <code>setTimeout()</code> или <code>setInterval()</code>), то вы можете прописать специальный код для <em>совместимости с IE, </em><span class="VIiyi" lang="ru"><span class="ChMk0b JLqJ4b"><span>вставив этот код в начало ваших скриптов</span></span></span>, <span class="VIiyi" lang="ru"><span class="ChMk0b JLqJ4b"><span>который включит функцию передачи стандартных параметров HTML5 в </span></span></span>Internet Explorer<span class="VIiyi" lang="ru"><span class="ChMk0b JLqJ4b"><span> для обоих таймеров</span></span></span>.</p> -<pre class="brush: js notranslate">/*\ +<pre class="brush: js">/*\ |*| |*| IE-specific polyfill which enables the passage of arbitrary arguments to the |*| callback functions of JavaScript timers (HTML5 standard syntax). @@ -108,7 +108,7 @@ if (document.all && !window.setInterval.isPolyfill) { <p>If you want a completely unobtrusive hack for every other mobile or desktop browser, including IE 9 and below, you can either use JavaScript conditional comments:</p> -<pre class="brush: js notranslate">/*@cc_on +<pre class="brush: js">/*@cc_on // conditional IE < 9 only fix @if (@_jscript_version <= 6) (function(f){ @@ -121,7 +121,7 @@ if (document.all && !window.setInterval.isPolyfill) { <p><span class="VIiyi" lang="ru"><span class="ChMk0b JLqJ4b"><span>Или используйте очень чистый подход, основанный на условном свойстве IE HTML</span></span></span>:</p> -<pre class="brush: html notranslate"><!--[if lte IE 9]><script> +<pre class="brush: html"><!--[if lte IE 9]><script> (function(f){ window.setTimeout =f(window.setTimeout); window.setInterval =f(window.setInterval); @@ -133,12 +133,12 @@ var a=[].slice.call(arguments,2);return f(function(){c.apply(this,a)},t)} <p>Another possibility is to use an anonymous function to call your callback, but this solution is a bit more expensive. Example:</p> -<pre class="brush: js notranslate">var intervalID = setTimeout(function() { myFunc("one", "two", "three"); }, 1000); +<pre class="brush: js">var intervalID = setTimeout(function() { myFunc("one", "two", "three"); }, 1000); </pre> <p>Yet another possibility is to use <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind" title="/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind">function's bind</a>. Example:</p> -<pre class="brush: js notranslate">setTimeout(function(arg1){}.bind(undefined, 10)); +<pre class="brush: js">setTimeout(function(arg1){}.bind(undefined, 10)); </pre> <h2 id="Проблема_с_this">Проблема с "<code>this</code>"</h2> @@ -149,7 +149,7 @@ var a=[].slice.call(arguments,2);return f(function(){c.apply(this,a)},t)} <p>Code executed by <code>setTimeout()</code> is run in a separate execution context to the function from which it was called. As a consequence, the <code>this</code> keyword for the called function will be set to the <code>window</code> (or <code>global</code>) object; it will not be the same as the <code>this</code> value for the function that called <code>setTimeout</code>. See the following example:</p> -<pre class="brush: js notranslate">myArray = ["zero", "one", "two"]; +<pre class="brush: js">myArray = ["zero", "one", "two"]; myArray.myMethod = function (sProperty) { alert(arguments.length > 0 ? this[sProperty] : this); }; @@ -168,7 +168,7 @@ setTimeout.call(myArray, myArray.myMethod, 2500, 2); // same error</pre> <p>A possible way to solve the "<code>this</code>" problem is to replace the two native <code>setTimeout()</code> or <code>setInterval()</code> global functions with two <em>non-native</em> ones which will enable their invocation through the <a href="en-US/docs/JavaScript/Reference/Global_Objects/Function/call" title="en-US/docs/JavaScript/Reference/Global_Objects/Function/call"><code>Function.prototype.call</code></a> method. The following example shows a possible replacement:</p> -<pre class="brush: js notranslate">// Enable the passage of the 'this' object through the JavaScript timers +<pre class="brush: js">// Enable the passage of the 'this' object through the JavaScript timers var __nativeST__ = window.setTimeout, __nativeSI__ = window.setInterval; @@ -190,7 +190,7 @@ window.setInterval = function (vCallback, nDelay /*, argumentToPass1, argumentTo <p>Новая тестируемая особенность:</p> -<pre class="brush: js notranslate">myArray = ["zero", "one", "two"]; +<pre class="brush: js">myArray = ["zero", "one", "two"]; myArray.myMethod = function (sProperty) { alert(arguments.length > 0 ? this[sProperty] : this); }; @@ -214,7 +214,7 @@ setTimeout.call(myArray, myArray.myMethod, 2500, 2); // prints "two" after 2.5 s <p>Передача строки вместо функции в <code>setTimeout()</code> сопряжена с теми же опасностями, что и использование <code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/eval#Don.27t_use_eval.21" title="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/eval">eval</a>. </code></p> -<pre class="brush: js notranslate">// Правильно +<pre class="brush: js">// Правильно window.setTimeout(function() { alert("Hello World!"); }, 500); |