|
9 | 9 | | [Working with `<template>` tag](#working-with-template-tag) | |
10 | 10 | | [Loading Script Dynamically](#loading-script-dynamically) | |
11 | 11 | | [Setting Timers and Intervals](#setting-timers-and-intervals) | |
12 | | -| [The `location` and `history` Objects](#the-location-and-history-objects) |
| 12 | +| [The `location` and `history` Objects](#the-location-and-history-objects) | |
| 13 | +| [The `navigator` Object](#the-navigator-object) | |
13 | 14 |
|
14 | 15 | Below topics will be covered and for its practical application, [Planner Project](project_planner/) will be used as reference where concept of classes and functions are demonstrated: |
15 | 16 |
|
@@ -318,4 +319,38 @@ Readings: |
318 | 319 |
|
319 | 320 | - [JavaScript History](https://www.javascripttutorial.net/javascript-bom/javascript-history/) |
320 | 321 |
|
321 | | -- [JavaScript History Object](https://www.studytonight.com/javascript/javascript-history-object) |
| 322 | +- [JavaScript History Object](https://www.studytonight.com/javascript/javascript-history-object) |
| 323 | + |
| 324 | +## The [`navigator`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator) Object |
| 325 | + |
| 326 | +In the Document Object Model (DOM), the `navigator` object is used to get information about the user's browser and operating system. This object provides a lot of useful information that can be used to create better user experiences or to handle browser-specific issues. |
| 327 | + |
| 328 | +Here are some common properties of the navigator object: |
| 329 | + |
| 330 | +- `appName`: Returns the name of the browser. |
| 331 | +- `appVersion`: Returns the version number of the browser. |
| 332 | +- `userAgent`: Returns the user agent string that identifies the browser. |
| 333 | +- `language`: Returns the user's preferred language. |
| 334 | +- `platform`: Returns the user's operating system. |
| 335 | +- `plugins`: Returns a list of the plugins installed in the browser. |
| 336 | +- `cookieEnabled`: Returns true if cookies are enabled in the browser. |
| 337 | + |
| 338 | +You can access these properties of the navigator object using dot notation, like this: |
| 339 | + |
| 340 | +```javascript |
| 341 | +// Get the user agent string |
| 342 | +const userAgent = navigator.userAgent; |
| 343 | + |
| 344 | +// Get the name of the browser |
| 345 | +const browserName = navigator.appName; |
| 346 | +``` |
| 347 | + |
| 348 | +Note that the `navigator` object is not standardized and different browsers may implement it differently. As a result, you may need to test your code in multiple browsers to ensure compatibility. |
| 349 | + |
| 350 | +Readings: |
| 351 | + |
| 352 | +- [Browser detection using the user agent](https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent) |
| 353 | + |
| 354 | +- [Window: navigator property](https://developer.mozilla.org/en-US/docs/Web/API/Window/navigator#example_1_browser_detect_and_return_a_string) |
| 355 | + |
| 356 | +- [JavaScript Navigator](https://www.javascripttutorial.net/javascript-bom/javascript-navigator/) |
0 commit comments