Skip to content

Commit 1841238

Browse files
Add: CodeSandbox 118.
1 parent 366bc8b commit 1841238

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4214,7 +4214,7 @@ navigator.mediaDevices.getUserMedia({ audio: true, video: true })
42144214
document.body.appendChild(videoElement);
42154215
})
42164216
.catch(function(error) {
4217-
alert('getUserMedia error:', error);
4217+
alert('getUserMedia error: ' + error);
42184218
});
42194219
</script>
42204220
```
@@ -4247,7 +4247,7 @@ The Media Capture and Streams API enables web applications to capture audio, vid
42474247
- The `<input>` element has the `type` attribute set to `file` to create a file input control.
42484248
- The `accept` attribute specifies the file types that can be selected, in this case, only image files are allowed (`image/*`).
42494249
- The `capture` attribute instructs the browser to open the device's camera when the input is clicked, allowing the user to capture a photo directly from the camera.
4250-
- If your device is a desktop computer, you'll likely get a typical file picker. Please use a mobile device for this example.
4250+
- **If your device is a desktop computer, you'll likely get a typical file picker. Please use a mobile device for this example.**
42514251

42524252
#### Offline Applications and Service Workers
42534253

@@ -4261,15 +4261,21 @@ if ('serviceWorker' in navigator) {
42614261
window.addEventListener('load', function() {
42624262
navigator.serviceWorker.register('service-worker.js')
42634263
.then(function(registration) {
4264-
console.log('Service Worker registered with scope:', registration.scope);
4264+
alert('Service Worker registered with scope: ' + registration.scope);
42654265
})
42664266
.catch(function(error) {
4267-
console.error('Service Worker registration failed:', error);
4267+
alert('Service Worker registration failed: ' + error);
42684268
});
42694269
});
42704270
}
42714271
```
42724272

4273+
[![Edit 118-Implementing Offline Capabilities with Service Workers](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/p/sandbox/118-implementing-offline-capabilities-with-service-workers-zjm7tx)
4274+
4275+
- [^118]CodeSandbox: Implementing Offline Capabilities with Service Workers.
4276+
4277+
[^118]:[CodeSandbox: Implementing Offline Capabilities with Service Workers.](https://zjm7tx.csb.app/), last access: October 8, 2024.
4278+
42734279
- The code above demonstrates how to register a Service Worker for offline capabilities.
42744280
- First, it checks if the browser supports Service Workers.
42754281
- If supported, it registers the Service Worker script (`service-worker.js`) using the `register()` method.

0 commit comments

Comments
 (0)