diff options
Diffstat (limited to 'files/ru/web/api/network_information_api/index.html')
-rw-r--r-- | files/ru/web/api/network_information_api/index.html | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/files/ru/web/api/network_information_api/index.html b/files/ru/web/api/network_information_api/index.html index ca66acea26..808ca544f1 100644 --- a/files/ru/web/api/network_information_api/index.html +++ b/files/ru/web/api/network_information_api/index.html @@ -15,7 +15,7 @@ translation_of: Web/API/Network_Information_API <p>Данный пример отслеживает изменение подключения пользователя.</p> -<pre class="brush: js notranslate">var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; +<pre class="brush: js">var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; var type = connection.effectiveType; function updateConnectionStatus() { @@ -30,7 +30,7 @@ connection.addEventListener('change', updateConnectionStatus); <p>The connection object is useful for deciding whether to preload resources that take large amounts of bandwidth or memory. This example would be called soon after page load to check for a connection type where preloading a video may not be desirable. If a cellular connection is found, then the <code>preloadVideo</code> flag is set to false. For simplicity and clarity, this example only tests for one connection type. A real-world use case would likely use a switch statement or some other method to check all of the possible values of {{domxref("NetworkInformation.type")}}. Regardless of the <code>type</code> value you can get an estimate of connection speed through the {{domxref("NetworkInformation.effectiveType")}} property.</p> -<pre class="brush: js notranslate">let preloadVideo = true; +<pre class="brush: js">let preloadVideo = true; var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection; if (connection) { if (connection.effectiveType === 'slow-2g') { |