diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 5a5aae0145ac97d..070b25ba71797ec 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,8 @@ blank_issues_enabled: true contact_links: + - name: Baseline issue + url: https://github.com/web-platform-dx/web-features + about: Baseline issues should be reported in the repository hosting Baseline data. - name: Content or feature request url: https://github.com/mdn/mdn/issues/new/choose about: Propose new content for MDN Web Docs or submit a feature request using this link. diff --git a/.github/workflows/markdown-lint-fix.yml b/.github/workflows/auto-cleanup-bot.yml similarity index 69% rename from .github/workflows/markdown-lint-fix.yml rename to .github/workflows/auto-cleanup-bot.yml index feaeb7893138064..25861b4ad0da310 100644 --- a/.github/workflows/markdown-lint-fix.yml +++ b/.github/workflows/auto-cleanup-bot.yml @@ -1,4 +1,4 @@ -name: Create Markdownlint auto-fix PR +name: Create content auto-fix PR on: schedule: @@ -34,25 +34,31 @@ jobs: - name: Create PR with only fixable issues if: success() - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v6 with: - commit-message: "chore: auto-fix Markdownlint issues" + commit-message: "chore: auto-fix Markdownlint, Prettier, and front-matter issues" branch: markdownlint-auto-cleanup - title: "Markdownlint auto-cleanup" + title: "fix: auto-cleanup by bot" author: mdn-bot <108879845+mdn-bot@users.noreply.github.com> + committer: mdn-bot <108879845+mdn-bot@users.noreply.github.com> body: | All issues auto-fixed + labels: | + automated pr token: ${{ secrets.AUTOMERGE_TOKEN }} - name: Create PR with notice on unfixed issues if: failure() - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v6 with: - commit-message: "chore: auto-fix Markdownlint issues" + commit-message: "chore: auto-fix Markdownlint, Prettier, and front-matter issues" branch: markdownlint-auto-cleanup - title: "Markdownlint auto-cleanup" + title: "fix: auto-cleanup by bot" author: mdn-bot <108879845+mdn-bot@users.noreply.github.com> + committer: mdn-bot <108879845+mdn-bot@users.noreply.github.com> body: | Auto-fix was run, but additional issues found. Please review the run log: https://github.com/mdn/content/actions/runs/${{ github.run_id }} + labels: | + automated pr token: ${{ secrets.AUTOMERGE_TOKEN }} diff --git a/.github/workflows/interfacedata-updater.yml b/.github/workflows/interfacedata-updater.yml index 91c5e3afd221cdf..c02f95d3f87d9c9 100644 --- a/.github/workflows/interfacedata-updater.yml +++ b/.github/workflows/interfacedata-updater.yml @@ -22,6 +22,7 @@ jobs: uses: actions/setup-node@v4 with: node-version-file: "mdn-content/.nvmrc" + cache: yarn - name: Checkout webref uses: actions/checkout@v4 @@ -35,13 +36,16 @@ jobs: run: node scripts/update-interface-data.js ../webref/ - name: Create pull request - uses: peter-evans/create-pull-request@v5 + uses: peter-evans/create-pull-request@v6 with: path: mdn-content token: ${{ secrets.AUTOMERGE_TOKEN }} title: Update InterfaceData based on WebRef author: mdn-bot <108879845+mdn-bot@users.noreply.github.com> + committer: mdn-bot <108879845+mdn-bot@users.noreply.github.com> commit-message: Update InterfaceData based on WebRef body: Automated changes generated by scripts/update-interface-data via interface-updater github workflow + labels: | + automated pr delete-branch: true branch: interfacedata-update diff --git a/.github/workflows/issue-regex-labeler.yml b/.github/workflows/issue-regex-labeler.yml index dd777a5c65711ea..a300a12f776ab69 100644 --- a/.github/workflows/issue-regex-labeler.yml +++ b/.github/workflows/issue-regex-labeler.yml @@ -7,7 +7,7 @@ jobs: issue-labeler: runs-on: ubuntu-latest steps: - - uses: github/issue-labeler@v3.3 + - uses: github/issue-labeler@v3.4 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" configuration-path: .github/issue-regex-labeler.yml diff --git a/.github/workflows/on-demand-preview-build.yml b/.github/workflows/on-demand-preview-build.yml index 2a09bf32dd84ee8..0dec5529814a03a 100644 --- a/.github/workflows/on-demand-preview-build.yml +++ b/.github/workflows/on-demand-preview-build.yml @@ -108,7 +108,7 @@ jobs: # See https://www.peterbe.com/plog/install-python-poetry-github-actions-faster - name: Load cached ~/.local - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.local # the trailing number is used to increase for getting @@ -123,7 +123,7 @@ jobs: - name: Load cached venv id: cached-poetry-dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: yari/deployer/.venv key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ hashFiles('.github/workflows/pr-review-companion.yml') }} diff --git a/.github/workflows/ping-other-repos.yml b/.github/workflows/ping-other-repos.yml index c5a6dda65c42c30..a49d93c7fd083cb 100644 --- a/.github/workflows/ping-other-repos.yml +++ b/.github/workflows/ping-other-repos.yml @@ -22,7 +22,7 @@ jobs: - name: Ping w3c/mdn-spec-links # This is one of many possible repos we can ping. When adding other # repos, you can follow this w3c/mdn-spec-links one as an example. - uses: peter-evans/repository-dispatch@v2 + uses: peter-evans/repository-dispatch@v3 with: token: ${{ secrets.REPO_PINGER_MDN_SPEC_LINKS }} repository: w3c/mdn-spec-links diff --git a/.github/workflows/pr-check_redirects.yml b/.github/workflows/pr-check_redirects.yml index 7338099f039100b..a2dd6e9c46ac8cc 100644 --- a/.github/workflows/pr-check_redirects.yml +++ b/.github/workflows/pr-check_redirects.yml @@ -21,7 +21,7 @@ jobs: # This is a "required" workflow so path filtering can not be used: # https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/troubleshooting-required-status-checks#handling-skipped-but-required-checks # We have to rely on a custom filtering mechanism to run the checks only if required files are modified. - - uses: dorny/paths-filter@v2 + - uses: dorny/paths-filter@v3 name: See if any file needs checking id: filter with: diff --git a/.github/workflows/pr-check_url-issues.yml b/.github/workflows/pr-check_url-issues.yml new file mode 100644 index 000000000000000..96398ea0f37e6b5 --- /dev/null +++ b/.github/workflows/pr-check_url-issues.yml @@ -0,0 +1,30 @@ +name: Check URL issues + +on: + pull_request: + branches: + - main + paths: + - "files/**/*.md" + +jobs: + check_url_issues: + #if: github.repository == 'mdn/content' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js environment + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + cache: yarn + + - name: Check URL deletions and broken fragments + run: | + echo "::add-matcher::.github/workflows/url-issues-problem-matcher.json" + git fetch origin main + node scripts/log-url-issues.js --workflow diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml index ee022815cf67a7a..204899d098e0e1a 100644 --- a/.github/workflows/pr-labeler.yml +++ b/.github/workflows/pr-labeler.yml @@ -1,13 +1,48 @@ -name: "Pull request labeler" +name: PR labeler + on: - pull_request_target +permissions: + issues: write + pull-requests: write + contents: read + jobs: - triage: + # Docs: https://github.com/actions/labeler + label-by-path: # do not run on forks if: github.repository == 'mdn/content' + name: Label by path runs-on: ubuntu-latest steps: - uses: actions/labeler@v4 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" + + # Docs: https://github.com/CodelyTV/pr-size-labeler + label-by-size: + # do not run on forks + if: github.repository == 'mdn/content' + needs: label-by-path + name: Label by size + runs-on: ubuntu-latest + steps: + - uses: codelytv/pr-size-labeler@v1 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + github_api_url: "https://api.github.com" + xs_label: "size/xs" + xs_max_size: "5" + s_label: "size/s" + s_max_size: "50" + m_label: "size/m" + m_max_size: "500" + l_label: "size/l" + l_max_size: "1000" + xl_label: "size/xl" + fail_if_xl: "false" + message_if_xl: "" + files_to_ignore: | + "files/en-us/_redirects.txt" + "files/en-us/_wikihistory.json" diff --git a/.github/workflows/pr-review-companion.yml b/.github/workflows/pr-review-companion.yml index dd84e0b469dd82b..4a1fcf3f4921b73 100644 --- a/.github/workflows/pr-review-companion.yml +++ b/.github/workflows/pr-review-companion.yml @@ -30,7 +30,7 @@ jobs: # See https://www.peterbe.com/plog/install-python-poetry-github-actions-faster - name: Load cached ~/.local - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.local # the trailing number is used to increase for getting @@ -45,7 +45,7 @@ jobs: - name: Load cached venv id: cached-poetry-dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: yari/deployer/.venv # the trailing number is used to increase for getting diff --git a/.github/workflows/url-issues-problem-matcher.json b/.github/workflows/url-issues-problem-matcher.json new file mode 100644 index 000000000000000..552686c42e47baf --- /dev/null +++ b/.github/workflows/url-issues-problem-matcher.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "owner": "log-url-issues", + "severity": "error", + "pattern": [ + { + "regexp": "^(ERROR|WARN|INFO):(.+):(\\d+):(\\d+):(.+)$", + "severity": 1, + "file": 2, + "line": 3, + "column": 4, + "message": 5 + } + ] + } + ] +} diff --git a/.husky/post-merge b/.husky/post-merge new file mode 100644 index 000000000000000..292651593e42a37 --- /dev/null +++ b/.husky/post-merge @@ -0,0 +1,16 @@ +#!/usr/bin/env sh + +BRANCH="$(git rev-parse --abbrev-ref HEAD)" +if [ "$BRANCH" != "main" ]; then + exit 0 +fi + +if [ -f ".husky/_/history" ]; then + lastHash=$(cat ./.husky/_/history) + isUpdated=$(git diff $lastHash HEAD -- ./package.json) + if [ "$isUpdated" != "" ]; then + echo "\n⚠🔥 'package.json' has changed. Please run 'yarn install'! 🔥" + fi +else + yarn install +fi diff --git a/.husky/pre-commit b/.husky/pre-commit index 36af219892fda8e..2312dc587f61186 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - npx lint-staged diff --git a/.husky/update-history b/.husky/update-history new file mode 100644 index 000000000000000..8acaf333a7f745a --- /dev/null +++ b/.husky/update-history @@ -0,0 +1,9 @@ +#!/usr/bin/env sh + +# This script stores the 'main' branch's HEAD commit hash in .husky/_/history +# The stored commit hash is used by the post-merge script .husky/post-merge + +BRANCH="$(git rev-parse --abbrev-ref HEAD)" +if [ "$BRANCH" = "main" -a -d "./.husky/_" ]; then + echo $(git rev-parse HEAD) > ./.husky/_/history +fi diff --git a/.lintstagedrc.json b/.lintstagedrc.json index 9e259f12baf57f8..affa61f1dd480a6 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -3,8 +3,10 @@ "*.md": [ "markdownlint-cli2 --fix", "node scripts/front-matter_linter.js --fix true", + "node scripts/update-moved-file-links.js --check", "prettier --write" ], "tests/**/*.*": "yarn test:front-matter-linter", - "*.{svg,png,jpeg,jpg,gif}": "yarn filecheck" + "*.{svg,png,jpeg,jpg,gif}": "yarn filecheck", + "*": "node scripts/log-url-issues.js" } diff --git a/.markdownlint-cli2.jsonc b/.markdownlint-cli2.jsonc index 5e01c3a409f01ec..892510a33078fcb 100644 --- a/.markdownlint-cli2.jsonc +++ b/.markdownlint-cli2.jsonc @@ -1,7 +1,7 @@ { "config": { - "extends": "./.markdownlint.jsonc" + "extends": "./.markdownlint.jsonc", }, "customRules": ["markdownlint-rule-search-replace"], - "ignores": ["node_modules", ".git", ".github", "tests"] + "ignores": ["node_modules", ".git", ".github", "tests"], } diff --git a/.markdownlint.jsonc b/.markdownlint.jsonc index d07886f1046e24b..2ccae5139144109 100644 --- a/.markdownlint.jsonc +++ b/.markdownlint.jsonc @@ -7,29 +7,29 @@ // Disabled, as some callouts include headings. "heading-increment": false, "ul-style": { - "style": "dash" + "style": "dash", }, "ul-indent": { - "indent": 2 + "indent": 2, }, "no-hard-tabs": { - "spaces_per_tab": 2 + "spaces_per_tab": 2, }, "line-length": false, "no-duplicate-heading": { - "allow_different_nesting": true + "siblings_only": true, }, "single-title": { - "front_matter_title": "^\\s*title\\s*[:=]" + "front_matter_title": "^\\s*title\\s*[:=]", }, "no-trailing-punctuation": { - "punctuation": ".,;:" + "punctuation": ".,;:", }, // Consecutive Notes/Callouts currently don't conform with this rule "no-blanks-blockquote": false, // Force ordered numbering to catch accidental list ending from indenting "ol-prefix": { - "style": "ordered" + "style": "ordered", }, "no-inline-html": { "allowed_elements": [ @@ -99,8 +99,8 @@ "thead", "tr", "ul", - "var" - ] + "var", + ], }, "no-bare-urls": false, // Produces too many false positives @@ -109,13 +109,13 @@ // See https://github.com/mdn/content/pull/20026, as macros currently break this "no-empty-links": false, "code-block-style": { - "style": "fenced" + "style": "fenced", }, "emphasis-style": { - "style": "underscore" + "style": "underscore", }, "strong-style": { - "style": "asterisk" + "style": "asterisk", }, // Disabled, as yari generates link fragments by replacing spaces with underscores, not dashes. "link-fragments": false, @@ -128,90 +128,90 @@ "message": "Don't use curly double quotes", "searchPattern": "/“|”/g", "replace": "\"", - "searchScope": "text" + "searchScope": "text", }, { "name": "curly-single-quotes", "message": "Don't use curly single quotes", "searchPattern": "/‘|’/g", "replace": "'", - "searchScope": "text" + "searchScope": "text", }, { "name": "nbsp", "message": "Don't use no-break spaces", "searchPattern": "/ /g", "replace": " ", - "searchScope": "all" + "searchScope": "all", }, { "name": "m-dash", "message": "Don't use '--'. Use m-dash — instead", "search": " -- ", "replace": " — ", - "searchScope": "text" + "searchScope": "text", }, { "name": "relative-link", "message": "Internal links should start with '/'", "searchPattern": "/([\\(\"])en-US\\/docs/g", "replace": "$1/en-US/docs", - "searchScope": "text" + "searchScope": "text", }, { "name": "relative-link-path", "message": "Don't use relative paths", "search": "](..", - "searchScope": "text" + "searchScope": "text", }, { "name": "trailing-spaces", "message": "Avoid trailing spaces", "searchPattern": "/ +$/gm", "replace": "", - "searchScope": "all" + "searchScope": "all", }, { "name": "double-spaces", "message": "Avoid double spaces", "searchPattern": "/([^\\s>]) ([^\\s|])/g", "replace": "$1 $2", - "searchScope": "text" + "searchScope": "text", }, { "name": "stuck-definition", "message": "Character is stuck to definition description marker", "searchPattern": "/- :(\\w)/g", "replace": "- : $1", - "searchScope": "text" + "searchScope": "text", }, { "name": "fqdn-moz-links", "message": "Don't use developer.mozilla.org for links, except for blog posts", "searchPattern": "/\\]\\(https:\\/\\/developer.mozilla.org\\/(?!en-US\\/blog\\/)/g", "replace": "](/", - "searchScope": "text" + "searchScope": "text", }, { "name": "incorrect-spelling", "message": "Incorrect spelling", "searchPattern": ["/e-mail/ig", "/(w)eb site/ig"], "replace": ["email", "$1ebsite"], - "searchScope": "all" + "searchScope": "all", }, { "name": "localhost-links", "message": "Don't use localhost for links", "searchPattern": "/\\]\\(https?:\\/\\/localhost:\\d+\\//g", "replace": "](/", - "searchScope": "text" + "searchScope": "text", }, { "name": "un-closed-md-link", - "message": "Missng closing bracket ')'", + "message": "Missing closing bracket ')'", "searchPattern": "/(\\[[^\\]]*?\\]\\(([^\\)\\n]|\\([^\\)\\n]\\)|\\s[\"'])+?)(\\n|\\s|[,:][\\s\\n])/gm", - "searchScope": "text" - } - ] - } + "searchScope": "text", + }, + ], + }, } diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 3e0061fbdf88f76..0e7391244b949f4 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -68,5 +68,6 @@ "path": "./project-words.txt", "addWords": true } - ] + ], + "enableFiletypes": ["xml"] } diff --git a/.vscode/project-words.txt b/.vscode/project-words.txt index 827e5b55f869659..3b7b6d8e99f2076 100644 --- a/.vscode/project-words.txt +++ b/.vscode/project-words.txt @@ -6,6 +6,7 @@ bézier Bhattacharya Brosset callouts +cdylib CEST CIELAB cjpeg @@ -57,6 +58,7 @@ Paciello prophoto rgba ripgrep +rustc sctp srgb tabak diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 97f7c737e8769c8..b5f7151e1cebeeb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -223,7 +223,7 @@ To ensure that all MDN documents follow the same formatting, we use both [Pretti If you have a [local checkout](#forking-and-cloning-the-repository) of the repository and have [installed the dependencies](#preparing-the-project), or you are using [github.dev](https://github.dev), a pre-commit hook will be installed which automatically runs while making a commit. To save some headache and improve your work flow while authoring, you may wish to [configure your editor to automatically run Prettier](https://prettier.io/docs/en/editors.html). Alternatively, you may run `yarn fix:md` in the command line to manually format all Markdown files. -> **Note:** Automatically formatting changes does not work for pull requests opened using the GitHub Web UI as described in the ["Simple changes" section](#simple-changes). This may result in failed status checks on pull requests. If you're not sure about how to fix this, [get in touch with us](/en-US/docs/MDN/Community/Communication_channels) for help. +> **Note:** Automatically formatting changes does not work for pull requests opened using the GitHub Web UI as described in the ["Simple changes" section](#simple-changes). This may result in failed status checks on pull requests. If you're not sure about how to fix this, [get in touch with us][]! for help. ### Adding a new document @@ -274,7 +274,13 @@ Let's say you want to move the entire `/en-US/Learn/Accessibility` tree to `/en- yarn content move Learn/Accessibility Learn/A11y ``` -3. Commit all of the changes and push your branch to the remote: +3. Once files are moved we need to update references to those files in the other content files as well. Use following command to update all the references automatically in one go: + + ```bash + node scripts/update-moved-file-links.js + ``` + +4. Commit all the changes and push your branch to the remote: ```bash git add . @@ -413,7 +419,7 @@ There are some important rules of etiquette to remember that will help during th When contributing to the content you agree to license your contributions according to [our license](LICENSE.md). -[contribute page]: https://developer.mozilla.org/en-US/docs/MDN/Contribute +[contribute page]: https://developer.mozilla.org/en-US/docs/MDN/Community/Contributing [getting started with mdn web docs]: https://developer.mozilla.org/en-US/docs/MDN/Community/Contributing/Getting_started [getting ready to contribute]: https://developer.mozilla.org/en-US/docs/MDN/Community/Contributing/Getting_started#getting_ready_to_contribute [how to write in markdown]: https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Howto/Markdown_in_MDN diff --git a/files/en-us/_redirects.txt b/files/en-us/_redirects.txt index 0578a1896bc58ad..855e0e46bc91fd6 100644 --- a/files/en-us/_redirects.txt +++ b/files/en-us/_redirects.txt @@ -114,7 +114,6 @@ /en-US/docs/Accessibility/Accessible_dynamic_content /en-US/docs/Web/Accessibility/An_overview_of_accessible_web_applications_and_widgets /en-US/docs/Accessibility/Accessible_forms/alerts /en-US/docs/Web/Accessibility/ARIA /en-US/docs/Accessibility/An_overview_of_accessible_web_applications_and_widgets /en-US/docs/Web/Accessibility/An_overview_of_accessible_web_applications_and_widgets -/en-US/docs/Accessibility/Architecture /en-US/docs/Web/Accessibility/Architecture /en-US/docs/Accessibility/Community /en-US/docs/Web/Accessibility /en-US/docs/Accessibility/FAQ /en-US/docs/Web/Accessibility /en-US/docs/Accessibility/HTML_To_MSAA /en-US/docs/Web/Accessibility @@ -123,7 +122,6 @@ /en-US/docs/Accessibility/Keyboard-navigable_JavaScript_widgets /en-US/docs/Web/Accessibility/Keyboard-navigable_JavaScript_widgets /en-US/docs/Accessibility/Web_Development /en-US/docs/Web/Accessibility /en-US/docs/Accessibility/Web_applications_and_ARIA_FAQ /en-US/docs/Web/Accessibility/ARIA -/en-US/docs/Accessibility:Architecture /en-US/docs/Web/Accessibility/Architecture /en-US/docs/Accessibility:Community /en-US/docs/Web/Accessibility /en-US/docs/Accessibility_FAQ /en-US/docs/Web/Accessibility /en-US/docs/Accessibility_Information_for_Web_Authors /en-US/docs/Web/Accessibility/Information_for_Web_authors @@ -606,7 +604,7 @@ /en-US/docs/CSS/background-position /en-US/docs/Web/CSS/background-position /en-US/docs/CSS/background-repeat /en-US/docs/Web/CSS/background-repeat /en-US/docs/CSS/background-size /en-US/docs/Web/CSS/background-size -/en-US/docs/CSS/block_formatting_context /en-US/docs/Web/Guide/CSS/Block_formatting_context +/en-US/docs/CSS/block_formatting_context /en-US/docs/Web/CSS/CSS_display/Block_formatting_context /en-US/docs/CSS/border /en-US/docs/Web/CSS/border /en-US/docs/CSS/border-bottom /en-US/docs/Web/CSS/border-bottom /en-US/docs/CSS/border-bottom-color /en-US/docs/Web/CSS/border-bottom-color @@ -801,7 +799,7 @@ /en-US/docs/CSS/repeating-radial-gradient /en-US/docs/Web/CSS/gradient/repeating-radial-gradient /en-US/docs/CSS/resize /en-US/docs/Web/CSS/resize /en-US/docs/CSS/resolution /en-US/docs/Web/CSS/resolution -/en-US/docs/CSS/rgb /en-US/docs/Web/CSS/color_value#rgb()_and_rgba() +/en-US/docs/CSS/rgb /en-US/docs/Web/CSS/color_value/rgb /en-US/docs/CSS/right /en-US/docs/Web/CSS/right /en-US/docs/CSS/scroll /en-US/docs/Web/CSS/overflow /en-US/docs/CSS/shape /en-US/docs/Web/CSS/shape @@ -986,7 +984,7 @@ /en-US/docs/CSS:background-image /en-US/docs/Web/CSS/background-image /en-US/docs/CSS:background-position /en-US/docs/Web/CSS/background-position /en-US/docs/CSS:background-repeat /en-US/docs/Web/CSS/background-repeat -/en-US/docs/CSS:block_formatting_context /en-US/docs/Web/Guide/CSS/Block_formatting_context +/en-US/docs/CSS:block_formatting_context /en-US/docs/Web/CSS/CSS_display/Block_formatting_context /en-US/docs/CSS:border /en-US/docs/Web/CSS/border /en-US/docs/CSS:border-bottom /en-US/docs/Web/CSS/border-bottom /en-US/docs/CSS:border-bottom-color /en-US/docs/Web/CSS/border-bottom-color @@ -1232,7 +1230,7 @@ /en-US/docs/DOM/DOM_event_reference/compositionstart /en-US/docs/Web/API/Element/compositionstart_event /en-US/docs/DOM/DOM_event_reference/compositionupdate /en-US/docs/Web/API/Element/compositionupdate_event /en-US/docs/DOM/DOM_event_reference/error /en-US/docs/Web/API/HTMLElement/error_event -/en-US/docs/DOM/DOM_event_reference/input /en-US/docs/Web/API/HTMLElement/input_event +/en-US/docs/DOM/DOM_event_reference/input /en-US/docs/Web/API/Element/input_event /en-US/docs/DOM/DOM_event_reference/mouseenter /en-US/docs/Web/API/Element/mouseenter_event /en-US/docs/DOM/DOM_event_reference/mouseleave /en-US/docs/Web/API/Element/mouseleave_event /en-US/docs/DOM/DOM_event_reference/mousewheel /en-US/docs/Web/API/Element/mousewheel_event @@ -1459,7 +1457,7 @@ /en-US/docs/DOM/Mozilla_event_reference/gamepadconnected /en-US/docs/Web/API/Window/gamepadconnected_event /en-US/docs/DOM/Mozilla_event_reference/gamepaddisconnected /en-US/docs/Web/API/Window/gamepaddisconnected_event /en-US/docs/DOM/Mozilla_event_reference/hashchange /en-US/docs/Web/API/Window/hashchange_event -/en-US/docs/DOM/Mozilla_event_reference/input /en-US/docs/Web/API/HTMLElement/input_event +/en-US/docs/DOM/Mozilla_event_reference/input /en-US/docs/Web/API/Element/input_event /en-US/docs/DOM/Mozilla_event_reference/invalid /en-US/docs/Web/API/HTMLInputElement/invalid_event /en-US/docs/DOM/Mozilla_event_reference/keydown /en-US/docs/Web/API/Element/keydown_event /en-US/docs/DOM/Mozilla_event_reference/keypress /en-US/docs/Web/API/Element/keypress_event @@ -1574,7 +1572,6 @@ /en-US/docs/DOM/NodeList /en-US/docs/Web/API/NodeList /en-US/docs/DOM/NodeList.item /en-US/docs/Web/API/NodeList/item /en-US/docs/DOM/NodeList.item2 /en-US/docs/Web/API/NodeList/item -/en-US/docs/DOM/NotifyAudioAvailableEvent /en-US/docs/Web/API/NotifyAudioAvailableEvent /en-US/docs/DOM/Option /en-US/docs/Web/API/HTMLOptionElement/Option /en-US/docs/DOM/Orientation_and_motion_data_explained /en-US/docs/Web/API/Device_orientation_events/Orientation_and_motion_data_explained /en-US/docs/DOM/PannerNode /en-US/docs/Web/API/PannerNode @@ -2099,7 +2096,6 @@ /en-US/docs/DOM/window.content /en-US/docs/Web/API/Window /en-US/docs/DOM/window.crypto /en-US/docs/Web/API/crypto_property /en-US/docs/DOM/window.crypto.getRandomValues /en-US/docs/Web/API/Crypto/getRandomValues -/en-US/docs/DOM/window.defaultStatus /en-US/docs/Web/API/Window/defaultStatus /en-US/docs/DOM/window.document /en-US/docs/Web/API/Window/document /en-US/docs/DOM/window.dump /en-US/docs/Web/API/Window/dump /en-US/docs/DOM/window.escape /en-US/docs/Web/JavaScript/Reference/Global_Objects/escape @@ -2177,7 +2173,7 @@ /en-US/docs/DOM/window.onerror /en-US/docs/Web/API/Window/error_event /en-US/docs/DOM/window.onfocus /en-US/docs/Web/API/Window/focus_event /en-US/docs/DOM/window.onhashchange /en-US/docs/Web/API/Window/hashchange_event -/en-US/docs/DOM/window.oninput /en-US/docs/Web/API/HTMLElement/input_event +/en-US/docs/DOM/window.oninput /en-US/docs/Web/API/Element/input_event /en-US/docs/DOM/window.onkeydown /en-US/docs/Web/API/Element/keydown_event /en-US/docs/DOM/window.onkeypress /en-US/docs/Web/API/Element/keypress_event /en-US/docs/DOM/window.onkeyup /en-US/docs/Web/API/Element/keyup_event @@ -2559,7 +2555,6 @@ /en-US/docs/DOM:window.confirm /en-US/docs/Web/API/Window/confirm /en-US/docs/DOM:window.content /en-US/docs/Web/API/Window /en-US/docs/DOM:window.crypto /en-US/docs/Web/API/crypto_property -/en-US/docs/DOM:window.defaultStatus /en-US/docs/Web/API/Window/defaultStatus /en-US/docs/DOM:window.document /en-US/docs/Web/API/Window/document /en-US/docs/DOM:window.dump /en-US/docs/Web/API/Window/dump /en-US/docs/DOM:window.escape /en-US/docs/Web/JavaScript/Reference/Global_Objects/escape @@ -2896,7 +2891,6 @@ /en-US/docs/Document_Object_Model_(DOM)/NodeIterator.root /en-US/docs/Web/API/NodeIterator/root /en-US/docs/Document_Object_Model_(DOM)/NodeIterator.whatToShow /en-US/docs/Web/API/NodeIterator/whatToShow /en-US/docs/Document_Object_Model_(DOM)/NodeList /en-US/docs/Web/API/NodeList -/en-US/docs/Document_Object_Model_(DOM)/NotifyAudioAvailableEvent /en-US/docs/Web/API/NotifyAudioAvailableEvent /en-US/docs/Document_Object_Model_(DOM)/Orientation_and_motion_data_explained /en-US/docs/Web/API/Device_orientation_events/Orientation_and_motion_data_explained /en-US/docs/Document_Object_Model_(DOM)/Plugin /en-US/docs/Web/API/Plugin /en-US/docs/Document_Object_Model_(DOM)/PluginArray /en-US/docs/Web/API/PluginArray @@ -3274,7 +3268,6 @@ /en-US/docs/Document_Object_Model_(DOM)/window.content /en-US/docs/Web/API/Window /en-US/docs/Document_Object_Model_(DOM)/window.crypto /en-US/docs/Web/API/crypto_property /en-US/docs/Document_Object_Model_(DOM)/window.crypto.getRandomValues /en-US/docs/Web/API/Crypto/getRandomValues -/en-US/docs/Document_Object_Model_(DOM)/window.defaultStatus /en-US/docs/Web/API/Window/defaultStatus /en-US/docs/Document_Object_Model_(DOM)/window.document /en-US/docs/Web/API/Window/document /en-US/docs/Document_Object_Model_(DOM)/window.escape /en-US/docs/Web/JavaScript/Reference/Global_Objects/escape /en-US/docs/Document_Object_Model_(DOM)/window.forward /en-US/docs/Web/API/Window/forward @@ -3330,7 +3323,7 @@ /en-US/docs/Document_Object_Model_(DOM)/window.onerror /en-US/docs/Web/API/Window/error_event /en-US/docs/Document_Object_Model_(DOM)/window.onfocus /en-US/docs/Web/API/Window/focus_event /en-US/docs/Document_Object_Model_(DOM)/window.onhashchange /en-US/docs/Web/API/Window/hashchange_event -/en-US/docs/Document_Object_Model_(DOM)/window.oninput /en-US/docs/Web/API/HTMLElement/input_event +/en-US/docs/Document_Object_Model_(DOM)/window.oninput /en-US/docs/Web/API/Element/input_event /en-US/docs/Document_Object_Model_(DOM)/window.onkeydown /en-US/docs/Web/API/Element/keydown_event /en-US/docs/Document_Object_Model_(DOM)/window.onkeypress /en-US/docs/Web/API/Element/keypress_event /en-US/docs/Document_Object_Model_(DOM)/window.onkeyup /en-US/docs/Web/API/Element/keyup_event @@ -4003,7 +3996,7 @@ /en-US/docs/IMAP /en-US/docs/Glossary/IMAP /en-US/docs/IPv6 /en-US/docs/Glossary/IPv6 /en-US/docs/Inbox/Advance_HTML_Tags /en-US/docs/Learn/Common_questions/Design_and_accessibility/HTML_features_for_accessibility -/en-US/docs/Inbox/Advanced_layouts_with_flexbox /en-US/docs/Web/CSS/CSS_flexible_box_layout/Backwards_compatibility_of_flexbox +/en-US/docs/Inbox/Advanced_layouts_with_flexbox /en-US/docs/Glossary/Flexbox /en-US/docs/Inbox/Using_flexbox_to_lay_out_web_applications /en-US/docs/Web/CSS/CSS_flexible_box_layout/Typical_use_cases_of_flexbox /en-US/docs/Inbox/Writing_a_WebSocket_server_in_Java /en-US/docs/Web/API/WebSockets_API/Writing_a_WebSocket_server_in_Java /en-US/docs/Incorrect_MIME_Type_for_CSS_Files /en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types @@ -5156,7 +5149,7 @@ /en-US/docs/JavaScript_typed_arrays/Uint16Array /en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array /en-US/docs/JavaScript_typed_arrays/Uint32Array /en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array /en-US/docs/JavaScript_typed_arrays/Uint8Array /en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array -/en-US/docs/Learn/Advanced_layouts_with_flexbox /en-US/docs/Web/CSS/CSS_flexible_box_layout/Backwards_compatibility_of_flexbox +/en-US/docs/Learn/Advanced_layouts_with_flexbox /en-US/docs/Glossary/Flexbox /en-US/docs/Learn/Anatomy_of_a_web_page /en-US/docs/Learn/Common_questions/Design_and_accessibility/Common_web_layouts /en-US/docs/Learn/CSS/Basic_text_styling_in_CSS /en-US/docs/Learn/CSS/Styling_text/Fundamentals /en-US/docs/Learn/CSS/Basics /en-US/docs/Learn/CSS/First_steps @@ -5403,11 +5396,15 @@ /en-US/docs/Liberty!_Equality!_Validity! /en-US/docs/Learn/HTML/Introduction_to_HTML/Debugging_HTML /en-US/docs/Link_prefetching_FAQ /en-US/docs/Glossary/Prefetch /en-US/docs/Localization /en-US/docs/Glossary/Localization -/en-US/docs/MDC:How_to_Help /en-US/docs/MDN/Contribute +/en-US/docs/MDC:How_to_Help /en-US/docs/MDN/Community/Contributing /en-US/docs/MDN/About /en-US/docs/MDN/Writing_guidelines -/en-US/docs/MDN/At_ten/Contributing_to_MDN /en-US/docs/MDN/Contribute +/en-US/docs/MDN/At_ten/Contributing_to_MDN /en-US/docs/MDN/Community/Contributing /en-US/docs/MDN/Community/Issues/Issue_triage /en-US/docs/MDN/Community/Issues +/en-US/docs/MDN/Community/MDN_content /en-US/docs/MDN/Community/Contributing +/en-US/docs/MDN/Community/MDN_content/Issues /en-US/docs/MDN/Community/Issues +/en-US/docs/MDN/Community/MDN_content/Pull_requests /en-US/docs/MDN/Community/Pull_requests /en-US/docs/MDN/Community/Users_teams /en-US/docs/MDN/Community/Roles_teams +/en-US/docs/MDN/Contribute /en-US/docs/MDN/Community/Contributing /en-US/docs/MDN/Contribute/Changelog /en-US/docs/MDN/Changelog /en-US/docs/MDN/Contribute/Code_sample_guidelines /en-US/docs/MDN/Writing_guidelines/Writing_style_guide/Code_style_guide /en-US/docs/MDN/Contribute/Content /en-US/docs/MDN/Writing_guidelines @@ -5417,15 +5414,15 @@ /en-US/docs/MDN/Contribute/Content/Layout/Reference_page /en-US/docs/MDN/Writing_guidelines/Howto/Write_an_API_reference /en-US/docs/MDN/Contribute/Content/Layout/Reference_subpage /en-US/docs/MDN/Writing_guidelines/Howto/Write_an_API_reference /en-US/docs/MDN/Contribute/Content/Macros /en-US/docs/MDN/Writing_guidelines/Page_structures/Macros -/en-US/docs/MDN/Contribute/Content/Quicklinks /en-US/docs/MDN/Writing_guidelines/Page_structures/Quicklinks +/en-US/docs/MDN/Contribute/Content/Quicklinks /en-US/docs/MDN/Writing_guidelines/Page_structures/Sidebars /en-US/docs/MDN/Contribute/Content/Specification_tables /en-US/docs/MDN/Writing_guidelines/Page_structures/Specification_tables /en-US/docs/MDN/Contribute/Content/Style_guide /en-US/docs/MDN/Writing_guidelines/Writing_style_guide /en-US/docs/MDN/Contribute/Creating_and_editing_pages /en-US/docs/MDN/Writing_guidelines/Howto/Creating_moving_deleting /en-US/docs/MDN/Contribute/Does_this_belong /en-US/docs/MDN/Writing_guidelines/What_we_write /en-US/docs/MDN/Contribute/Editor/Live_samples /en-US/docs/MDN/Writing_guidelines/Page_structures/Live_samples -/en-US/docs/MDN/Contribute/FAQ /en-US/docs/MDN/Contribute +/en-US/docs/MDN/Contribute/FAQ /en-US/docs/MDN/Community/Contributing /en-US/docs/MDN/Contribute/Feedback /en-US/docs/MDN/Community -/en-US/docs/MDN/Contribute/Fixing_MDN_content_bugs /en-US/docs/MDN/Community/MDN_content +/en-US/docs/MDN/Contribute/Fixing_MDN_content_bugs /en-US/docs/MDN/Community/Contributing /en-US/docs/MDN/Contribute/Getting_started /en-US/docs/MDN/Community/Contributing/Getting_started /en-US/docs/MDN/Contribute/GitHub_beginners /en-US/docs/MDN/Community/Contributing/Getting_started /en-US/docs/MDN/Contribute/GitHub_best_practices /en-US/docs/MDN/Community/Issues @@ -5450,14 +5447,14 @@ /en-US/docs/MDN/Contribute/Guidelines/Layout/Reference_page /en-US/docs/MDN/Writing_guidelines/Howto/Write_an_API_reference /en-US/docs/MDN/Contribute/Guidelines/Layout/Reference_subpage /en-US/docs/MDN/Writing_guidelines/Howto/Write_an_API_reference /en-US/docs/MDN/Contribute/Guidelines/Macros /en-US/docs/MDN/Writing_guidelines/Page_structures/Macros -/en-US/docs/MDN/Contribute/Guidelines/Quicklinks /en-US/docs/MDN/Writing_guidelines/Page_structures/Quicklinks +/en-US/docs/MDN/Contribute/Guidelines/Quicklinks /en-US/docs/MDN/Writing_guidelines/Page_structures/Sidebars /en-US/docs/MDN/Contribute/Guidelines/Specification_tables /en-US/docs/MDN/Writing_guidelines/Page_structures/Specification_tables /en-US/docs/MDN/Contribute/Guidelines/Style_guide /en-US/docs/MDN/Writing_guidelines/Writing_style_guide /en-US/docs/MDN/Contribute/Guidelines/Video /en-US/docs/MDN/Writing_guidelines/Howto/Images_media /en-US/docs/MDN/Contribute/Guidelines/Writing_style_guide /en-US/docs/MDN/Writing_guidelines/Writing_style_guide /en-US/docs/MDN/Contribute/Help_beginners /en-US/docs/MDN/Community/Learn_forum /en-US/docs/MDN/Contribute/How_to_document_a_CSS_property /en-US/docs/MDN/Writing_guidelines/Howto/Document_a_CSS_property -/en-US/docs/MDN/Contribute/Howto /en-US/docs/MDN/Contribute +/en-US/docs/MDN/Contribute/Howto /en-US/docs/MDN/Community/Contributing /en-US/docs/MDN/Contribute/Howto/Add_or_update_browser_compatibility_data https://github.com/mdn/browser-compat-data/blob/main/docs/contributing.md /en-US/docs/MDN/Contribute/Howto/Compatibility_tables /en-US/docs/MDN/Writing_guidelines/Page_structures/Compatibility_tables /en-US/docs/MDN/Contribute/Howto/Convert_code_samples_to_be_live /en-US/docs/MDN/Writing_guidelines/Page_structures/Live_samples @@ -5480,11 +5477,13 @@ /en-US/docs/MDN/Contribute/Localize /en-US/docs/MDN/Community/Contributing/Translated_content /en-US/docs/MDN/Contribute/Markdown_in_MDN /en-US/docs/MDN/Writing_guidelines/Howto/Markdown_in_MDN /en-US/docs/MDN/Contribute/Open_source_etiquette /en-US/docs/MDN/Community/Open_source_etiquette +/en-US/docs/MDN/Contribute/Processes /en-US/docs/MDN/Community/Contributing /en-US/docs/MDN/Contribute/Processes/Content_bug_triage /en-US/docs/MDN/Community/Issues /en-US/docs/MDN/Contribute/Processes/Locating_browser-specific_information https://github.com/mdn/browser-compat-data/blob/main/docs/matching-browser-releases/index.md /en-US/docs/MDN/Contribute/Processes/Matching_features_to_browser_version https://github.com/mdn/browser-compat-data/blob/main/docs/matching-browser-releases/index.md /en-US/docs/MDN/Contribute/Processes/Matching_features_to_browser_versiosn https://github.com/mdn/browser-compat-data/blob/main/docs/matching-browser-releases/index.md -/en-US/docs/MDN/Contribute/Processes/Short_surveys /en-US/docs/MDN/Contribute +/en-US/docs/MDN/Contribute/Processes/Short_surveys /en-US/docs/MDN/Community/Contributing +/en-US/docs/MDN/Contribute/Processes/Workstream_assessment_project /en-US/docs/MDN/Community/Contributing /en-US/docs/MDN/Contribute/Sample_app_coding_guidelines /en-US/docs/MDN/Writing_guidelines/Writing_style_guide/Code_style_guide /en-US/docs/MDN/Contribute/Sample_server /en-US/docs/MDN /en-US/docs/MDN/Contribute/Structures /en-US/docs/MDN/Writing_guidelines/Page_structures @@ -5513,7 +5512,7 @@ /en-US/docs/MDN/Contribute/Structures/Page_types/HTML_element_page_template /en-US/docs/MDN/Writing_guidelines/Page_structures/Page_types/HTML_element_page_template /en-US/docs/MDN/Contribute/Structures/Page_types/HTTP_header_page_template /en-US/docs/MDN/Writing_guidelines/Page_structures/Page_types/HTTP_header_page_template /en-US/docs/MDN/Contribute/Structures/Page_types/SVG_element_page_template /en-US/docs/MDN/Writing_guidelines/Page_structures/Page_types/SVG_element_page_template -/en-US/docs/MDN/Contribute/Structures/Quicklinks /en-US/docs/MDN/Writing_guidelines/Page_structures/Quicklinks +/en-US/docs/MDN/Contribute/Structures/Quicklinks /en-US/docs/MDN/Writing_guidelines/Page_structures/Sidebars /en-US/docs/MDN/Contribute/Structures/Specification_tables /en-US/docs/MDN/Writing_guidelines/Page_structures/Specification_tables /en-US/docs/MDN/Contribute/Structures/Syntax_sections /en-US/docs/MDN/Writing_guidelines/Page_structures/Syntax_sections /en-US/docs/MDN/Contribute/Style_guide /en-US/docs/MDN/Writing_guidelines @@ -5522,7 +5521,7 @@ /en-US/docs/MDN/Contribute/Style_guide/Custom_macros /en-US/docs/MDN/Writing_guidelines/Page_structures/Macros/Commonly_used_macros /en-US/docs/MDN/Contribute/Style_guide/Live_samples /en-US/docs/MDN/Writing_guidelines/Page_structures/Live_samples /en-US/docs/MDN/Contribute/Style_guide/Macros /en-US/docs/MDN/Writing_guidelines/Page_structures/Macros -/en-US/docs/MDN/Contribute/Style_guide/Quicklinks /en-US/docs/MDN/Writing_guidelines/Page_structures/Quicklinks +/en-US/docs/MDN/Contribute/Style_guide/Quicklinks /en-US/docs/MDN/Writing_guidelines/Page_structures/Sidebars /en-US/docs/MDN/Contribute/Style_guide/Specification_tables /en-US/docs/MDN/Writing_guidelines/Page_structures/Specification_tables /en-US/docs/MDN/Contribute/Tagging /en-US/docs/MDN/Writing_guidelines/Howto /en-US/docs/MDN/Contribute/Tasks /en-US/docs/MDN/Community/Contributing/Getting_started @@ -5590,7 +5589,7 @@ /en-US/docs/MDN/Structures/Page_types/HTML_element_page_template /en-US/docs/MDN/Writing_guidelines/Page_structures/Page_types/HTML_element_page_template /en-US/docs/MDN/Structures/Page_types/HTTP_header_page_template /en-US/docs/MDN/Writing_guidelines/Page_structures/Page_types/HTTP_header_page_template /en-US/docs/MDN/Structures/Page_types/SVG_element_page_template /en-US/docs/MDN/Writing_guidelines/Page_structures/Page_types/SVG_element_page_template -/en-US/docs/MDN/Structures/Quicklinks /en-US/docs/MDN/Writing_guidelines/Page_structures/Quicklinks +/en-US/docs/MDN/Structures/Quicklinks /en-US/docs/MDN/Writing_guidelines/Page_structures/Sidebars /en-US/docs/MDN/Structures/Specification_tables /en-US/docs/MDN/Writing_guidelines/Page_structures/Specification_tables /en-US/docs/MDN/Structures/Syntax_sections /en-US/docs/MDN/Writing_guidelines/Page_structures/Syntax_sections /en-US/docs/MDN/Tools https://github.com/mdn/yari/tree/main/docs @@ -5603,11 +5602,12 @@ /en-US/docs/MDN/User_guide/Troubleshooting_KumaScript_errors https://github.com/mdn/yari/tree/main/docs/kumascript/troubleshooting-errors.md /en-US/docs/MDN/Writing_guidelines/Creating_moving_deleting /en-US/docs/MDN/Writing_guidelines/Howto/Creating_moving_deleting /en-US/docs/MDN/Writing_guidelines/Howto/Tag /en-US/docs/MDN/Writing_guidelines/Howto +/en-US/docs/MDN/Writing_guidelines/Page_structures/Quicklinks /en-US/docs/MDN/Writing_guidelines/Page_structures/Sidebars /en-US/docs/MDN/Writing_guidelines/Research_technology /en-US/docs/MDN/Writing_guidelines/Howto/Research_technology /en-US/docs/MDN/Writing_guidelines/What_we_write/Inclusion_criteria /en-US/docs/MDN/Writing_guidelines/What_we_write/Criteria_for_inclusion /en-US/docs/MDN/Yari https://github.com/mdn/yari/tree/main/docs /en-US/docs/MDN_at_ten /en-US/docs/MDN/At_ten -/en-US/docs/MDN_at_ten/Contributing_to_MDN /en-US/docs/MDN/Contribute +/en-US/docs/MDN_at_ten/Contributing_to_MDN /en-US/docs/MDN/Community/Contributing /en-US/docs/MDN_at_ten/History /en-US/docs/MDN/At_ten/History_of_MDN /en-US/docs/MDN_at_ten/History_of_MDN /en-US/docs/MDN/At_ten/History_of_MDN /en-US/docs/Main_page /en-US/ @@ -5660,7 +5660,7 @@ /en-US/docs/Media_Streams_API /en-US/docs/Web/API/Media_Capture_and_Streams_API /en-US/docs/Media_formats_supported_by_the_audio_and_video_elements /en-US/docs/Web/Media/Formats /en-US/docs/Memory_Sanitizer https://firefox-source-docs.mozilla.org/tools/sanitizer/memory_sanitizer.html#memory-sanitizer -/en-US/docs/Mobile/Mobile_Web_Development /en-US/docs/Web/Guide/Mobile +/en-US/docs/Mobile/Mobile_Web_Development /en-US/docs/Learn/CSS/CSS_layout/Responsive_Design /en-US/docs/MouseEvent.initMouseEvent /en-US/docs/Web/API/MouseEvent/initMouseEvent /en-US/docs/Mozilla's_Quirks_Mode /en-US/docs/Web/HTML/Quirks_Mode_and_Standards_Mode /en-US/docs/Mozilla/Add-ons/AMO/Policy https://extensionworkshop.com/documentation/publish/add-on-policies/ @@ -6269,7 +6269,7 @@ /en-US/docs/Mozilla_event_reference/gamepadconnected /en-US/docs/Web/API/Window/gamepadconnected_event /en-US/docs/Mozilla_event_reference/gamepaddisconnected /en-US/docs/Web/API/Window/gamepaddisconnected_event /en-US/docs/Mozilla_event_reference/hashchange /en-US/docs/Web/API/Window/hashchange_event -/en-US/docs/Mozilla_event_reference/input /en-US/docs/Web/API/HTMLElement/input_event +/en-US/docs/Mozilla_event_reference/input /en-US/docs/Web/API/Element/input_event /en-US/docs/Mozilla_event_reference/invalid /en-US/docs/Web/API/HTMLInputElement/invalid_event /en-US/docs/Mozilla_event_reference/keydown /en-US/docs/Web/API/Element/keydown_event /en-US/docs/Mozilla_event_reference/keypress /en-US/docs/Web/API/Element/keypress_event @@ -6497,8 +6497,6 @@ /en-US/docs/SVG/Attribute/color-interpolation /en-US/docs/Web/SVG/Attribute/color-interpolation /en-US/docs/SVG/Attribute/color-interpolation-filters /en-US/docs/Web/SVG/Attribute/color-interpolation-filters /en-US/docs/SVG/Attribute/color-profile /en-US/docs/Web/SVG/Attribute/color-profile -/en-US/docs/SVG/Attribute/contentScriptType /en-US/docs/Web/SVG/Attribute/contentScriptType -/en-US/docs/SVG/Attribute/contentStyleType /en-US/docs/Web/SVG/Attribute/contentStyleType /en-US/docs/SVG/Attribute/cursor /en-US/docs/Web/SVG/Attribute/cursor /en-US/docs/SVG/Attribute/cx /en-US/docs/Web/SVG/Attribute/cx /en-US/docs/SVG/Attribute/cy /en-US/docs/Web/SVG/Attribute/cy @@ -6518,7 +6516,6 @@ /en-US/docs/SVG/Attribute/fill-opacity /en-US/docs/Web/SVG/Attribute/fill-opacity /en-US/docs/SVG/Attribute/fill-rule /en-US/docs/Web/SVG/Attribute/fill-rule /en-US/docs/SVG/Attribute/filter /en-US/docs/Web/SVG/Attribute/filter -/en-US/docs/SVG/Attribute/filterRes /en-US/docs/Web/SVG/Attribute/filterRes /en-US/docs/SVG/Attribute/filterUnits /en-US/docs/Web/SVG/Attribute/filterUnits /en-US/docs/SVG/Attribute/flood-color /en-US/docs/Web/SVG/Attribute/flood-color /en-US/docs/SVG/Attribute/flood-opacity /en-US/docs/Web/SVG/Attribute/flood-opacity @@ -7589,7 +7586,6 @@ /en-US/docs/Web/API/BlobBuilder /en-US/docs/Web/API/Blob /en-US/docs/Web/API/BlobEvent.BlobEvent /en-US/docs/Web/API/BlobEvent/BlobEvent /en-US/docs/Web/API/BlobEvent.data /en-US/docs/Web/API/BlobEvent/data -/en-US/docs/Web/API/Bluetooth/onavailabilitychanged /en-US/docs/Web/API/Bluetooth/availabilitychanged_event /en-US/docs/Web/API/BluetoothAdvertisingData /en-US/docs/Web/API/Web_Bluetooth_API /en-US/docs/Web/API/BluetoothAdvertisingData/appearance /en-US/docs/Web/API/Web_Bluetooth_API /en-US/docs/Web/API/BluetoothAdvertisingData/manufacturerData /en-US/docs/Web/API/Web_Bluetooth_API @@ -7962,6 +7958,7 @@ /en-US/docs/Web/API/Document/keydown_event /en-US/docs/Web/API/Element/keydown_event /en-US/docs/Web/API/Document/keypress_event /en-US/docs/Web/API/Element/keypress_event /en-US/docs/Web/API/Document/keyup_event /en-US/docs/Web/API/Element/keyup_event +/en-US/docs/Web/API/Document/lostpointercapture_event /en-US/docs/Web/API/Element/lostpointercapture_event /en-US/docs/Web/API/Document/mozCancelFullScreen /en-US/docs/Web/API/Document/exitFullscreen /en-US/docs/Web/API/Document/mozFullScreenElement /en-US/docs/Web/API/Document/fullscreenElement /en-US/docs/Web/API/Document/mozFullScreenEnabled /en-US/docs/Web/API/Document/fullscreenEnabled @@ -7978,7 +7975,7 @@ /en-US/docs/Web/API/Document/onfocus /en-US/docs/Web/API/Window/focus_event /en-US/docs/Web/API/Document/onfullscreenchange /en-US/docs/Web/API/Document/fullscreenchange_event /en-US/docs/Web/API/Document/onfullscreenerror /en-US/docs/Web/API/Document/fullscreenerror_event -/en-US/docs/Web/API/Document/oninput /en-US/docs/Web/API/HTMLElement/input_event +/en-US/docs/Web/API/Document/oninput /en-US/docs/Web/API/Element/input_event /en-US/docs/Web/API/Document/onkeydown /en-US/docs/Web/API/Element/keydown_event /en-US/docs/Web/API/Document/onkeypress /en-US/docs/Web/API/Element/keypress_event /en-US/docs/Web/API/Document/onkeyup /en-US/docs/Web/API/Element/keyup_event @@ -8266,7 +8263,7 @@ /en-US/docs/Web/API/GlobalEventHandlers.ondblclick /en-US/docs/Web/API/Element/dblclick_event /en-US/docs/Web/API/GlobalEventHandlers.onerror /en-US/docs/Web/API/Window/error_event /en-US/docs/Web/API/GlobalEventHandlers.onfocus /en-US/docs/Web/API/Window/focus_event -/en-US/docs/Web/API/GlobalEventHandlers.oninput /en-US/docs/Web/API/HTMLElement/input_event +/en-US/docs/Web/API/GlobalEventHandlers.oninput /en-US/docs/Web/API/Element/input_event /en-US/docs/Web/API/GlobalEventHandlers.onkeydown /en-US/docs/Web/API/Element/keydown_event /en-US/docs/Web/API/GlobalEventHandlers.onkeypress /en-US/docs/Web/API/Element/keypress_event /en-US/docs/Web/API/GlobalEventHandlers.onkeyup /en-US/docs/Web/API/Element/keyup_event @@ -8327,7 +8324,7 @@ /en-US/docs/Web/API/GlobalEventHandlers/onfocus /en-US/docs/Web/API/Window/focus_event /en-US/docs/Web/API/GlobalEventHandlers/onformdata /en-US/docs/Web/API/HTMLFormElement/formdata_event /en-US/docs/Web/API/GlobalEventHandlers/ongotpointercapture /en-US/docs/Web/API/Element/gotpointercapture_event -/en-US/docs/Web/API/GlobalEventHandlers/oninput /en-US/docs/Web/API/HTMLElement/input_event +/en-US/docs/Web/API/GlobalEventHandlers/oninput /en-US/docs/Web/API/Element/input_event /en-US/docs/Web/API/GlobalEventHandlers/oninvalid /en-US/docs/Web/API/HTMLInputElement/invalid_event /en-US/docs/Web/API/GlobalEventHandlers/onkeydown /en-US/docs/Web/API/Element/keydown_event /en-US/docs/Web/API/GlobalEventHandlers/onkeypress /en-US/docs/Web/API/Element/keypress_event @@ -8411,7 +8408,7 @@ /en-US/docs/Web/API/HTMLContentElement.select /en-US/docs/Web/API/HTMLSlotElement /en-US/docs/Web/API/HTMLContentElement/getDistributedNodes /en-US/docs/Web/API/HTMLSlotElement /en-US/docs/Web/API/HTMLContentElement/select /en-US/docs/Web/API/HTMLSlotElement -/en-US/docs/Web/API/HTMLDialogElement/cancel /en-US/docs/Web/API/HTMLElement/cancel_event +/en-US/docs/Web/API/HTMLDialogElement/cancel_event /en-US/docs/Web/API/HTMLElement/cancel_event /en-US/docs/Web/API/HTMLDialogElement/close() /en-US/docs/Web/API/HTMLDialogElement/close /en-US/docs/Web/API/HTMLDialogElement/returnValue() /en-US/docs/Web/API/HTMLDialogElement/returnValue /en-US/docs/Web/API/HTMLDialogElement/show() /en-US/docs/Web/API/HTMLDialogElement/show @@ -8442,8 +8439,10 @@ /en-US/docs/Web/API/HTMLElement/animationend_event /en-US/docs/Web/API/Element/animationend_event /en-US/docs/Web/API/HTMLElement/animationiteration_event /en-US/docs/Web/API/Element/animationiteration_event /en-US/docs/Web/API/HTMLElement/animationstart_event /en-US/docs/Web/API/Element/animationstart_event +/en-US/docs/Web/API/HTMLElement/beforeinput_event /en-US/docs/Web/API/Element/beforeinput_event /en-US/docs/Web/API/HTMLElement/forceSpellCheck /en-US/docs/Web/HTML/Global_attributes/spellcheck /en-US/docs/Web/API/HTMLElement/gotpointercapture_event /en-US/docs/Web/API/Element/gotpointercapture_event +/en-US/docs/Web/API/HTMLElement/input_event /en-US/docs/Web/API/Element/input_event /en-US/docs/Web/API/HTMLElement/invalid_event /en-US/docs/Web/API/HTMLInputElement/invalid_event /en-US/docs/Web/API/HTMLElement/lostpointercapture_event /en-US/docs/Web/API/Element/lostpointercapture_event /en-US/docs/Web/API/HTMLElement/onabort /en-US/docs/Web/API/HTMLMediaElement/abort_event @@ -8455,7 +8454,7 @@ /en-US/docs/Web/API/HTMLElement/oncut /en-US/docs/Web/API/HTMLElement/cut_event /en-US/docs/Web/API/HTMLElement/ondblclick /en-US/docs/Web/API/Element/dblclick_event /en-US/docs/Web/API/HTMLElement/onfocus /en-US/docs/Web/API/Window/focus_event -/en-US/docs/Web/API/HTMLElement/oninput /en-US/docs/Web/API/HTMLElement/input_event +/en-US/docs/Web/API/HTMLElement/oninput /en-US/docs/Web/API/Element/input_event /en-US/docs/Web/API/HTMLElement/onkeydown /en-US/docs/Web/API/Element/keydown_event /en-US/docs/Web/API/HTMLElement/onkeypress /en-US/docs/Web/API/Element/keypress_event /en-US/docs/Web/API/HTMLElement/onkeyup /en-US/docs/Web/API/Element/keyup_event @@ -8560,6 +8559,7 @@ /en-US/docs/Web/API/HTMLSelectElement/HTMLSelectElement.disabled /en-US/docs/Web/API/HTMLSelectElement/disabled /en-US/docs/Web/API/HTMLSelectElement/HTMLSelectElement.form /en-US/docs/Web/API/HTMLSelectElement/form /en-US/docs/Web/API/HTMLSelectElement/HTMLSelectElement.selectedIndex /en-US/docs/Web/API/HTMLSelectElement/selectedIndex +/en-US/docs/Web/API/HTMLSelectElement/autofocus /en-US/docs/Web/API/HTMLElement/autofocus /en-US/docs/Web/API/HTMLStyleElement.media /en-US/docs/Web/API/HTMLStyleElement/media /en-US/docs/Web/API/HTMLStyleElement.scoped /en-US/docs/Web/API/HTMLStyleElement /en-US/docs/Web/API/HTMLStyleElement.type /en-US/docs/Web/API/HTMLStyleElement/type @@ -8617,6 +8617,7 @@ /en-US/docs/Web/API/Headers/getAll /en-US/docs/Web/API/Headers/get /en-US/docs/Web/API/History.length /en-US/docs/Web/API/History/length /en-US/docs/Web/API/History_API/Example /en-US/docs/Web/API/History_API/Working_with_the_History_API +/en-US/docs/Web/API/Houdini /en-US/docs/Web/API/Houdini_APIs /en-US/docs/Web/API/IDBCursor.advance /en-US/docs/Web/API/IDBCursor/advance /en-US/docs/Web/API/IDBCursor.continue /en-US/docs/Web/API/IDBCursor/continue /en-US/docs/Web/API/IDBCursor.delete /en-US/docs/Web/API/IDBCursor/delete @@ -8694,6 +8695,7 @@ /en-US/docs/Web/API/IDBKeyRange/lowerBound /en-US/docs/Web/API/IDBKeyRange/lowerBound_static /en-US/docs/Web/API/IDBKeyRange/only /en-US/docs/Web/API/IDBKeyRange/only_static /en-US/docs/Web/API/IDBKeyRange/upperBound /en-US/docs/Web/API/IDBKeyRange/upperBound_static +/en-US/docs/Web/API/IDBLocaleAwareKeyRange /en-US/docs/Web/API/IDBIndex /en-US/docs/Web/API/IDBMutableFile /en-US/docs/Web/API/IndexedDB_API /en-US/docs/Web/API/IDBMutableFile/abort_event /en-US/docs/Web/API/IndexedDB_API /en-US/docs/Web/API/IDBMutableFile/error_event /en-US/docs/Web/API/IndexedDB_API @@ -8795,8 +8797,8 @@ /en-US/docs/Web/API/InputDeviceCapabilities/fireTouchEvents /en-US/docs/Web/API/InputDeviceCapabilities/firesTouchEvents /en-US/docs/Web/API/InputEvent.InputEvent /en-US/docs/Web/API/InputEvent/InputEvent /en-US/docs/Web/API/InputEvent.isComposing /en-US/docs/Web/API/InputEvent/isComposing -/en-US/docs/Web/API/InputEvent/input /en-US/docs/Web/API/HTMLElement/input_event -/en-US/docs/Web/API/InputEvent/input_event /en-US/docs/Web/API/HTMLElement/input_event +/en-US/docs/Web/API/InputEvent/input /en-US/docs/Web/API/Element/input_event +/en-US/docs/Web/API/InputEvent/input_event /en-US/docs/Web/API/Element/input_event /en-US/docs/Web/API/InstallEvent/activeWorker /en-US/docs/Web/API/InstallEvent /en-US/docs/Web/API/Int16Array /en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array /en-US/docs/Web/API/Int32Array /en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array @@ -8911,7 +8913,7 @@ /en-US/docs/Web/API/MediaRecorder.onresume /en-US/docs/Web/API/MediaRecorder/resume_event /en-US/docs/Web/API/MediaRecorder.onstart /en-US/docs/Web/API/MediaRecorder/start_event /en-US/docs/Web/API/MediaRecorder.onstop /en-US/docs/Web/API/MediaRecorder/stop_event -/en-US/docs/Web/API/MediaRecorder.onwarning /en-US/docs/Web/API/MediaRecorder/warning_event +/en-US/docs/Web/API/MediaRecorder.onwarning /en-US/docs/Web/API/MediaRecorder /en-US/docs/Web/API/MediaRecorder.pause /en-US/docs/Web/API/MediaRecorder/pause /en-US/docs/Web/API/MediaRecorder.requestData /en-US/docs/Web/API/MediaRecorder/requestData /en-US/docs/Web/API/MediaRecorder.resume /en-US/docs/Web/API/MediaRecorder/resume @@ -8927,7 +8929,8 @@ /en-US/docs/Web/API/MediaRecorder/onresume /en-US/docs/Web/API/MediaRecorder/resume_event /en-US/docs/Web/API/MediaRecorder/onstart /en-US/docs/Web/API/MediaRecorder/start_event /en-US/docs/Web/API/MediaRecorder/onstop /en-US/docs/Web/API/MediaRecorder/stop_event -/en-US/docs/Web/API/MediaRecorder/onwarning /en-US/docs/Web/API/MediaRecorder/warning_event +/en-US/docs/Web/API/MediaRecorder/onwarning /en-US/docs/Web/API/MediaRecorder +/en-US/docs/Web/API/MediaRecorder/warning_event /en-US/docs/Web/API/MediaRecorder /en-US/docs/Web/API/MediaRecorder_API /en-US/docs/Web/API/MediaStream_Recording_API /en-US/docs/Web/API/MediaRecorder_API/Using_the_MediaRecorder_API /en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API /en-US/docs/Web/API/MediaSessionAction /en-US/docs/Web/API/MediaSession/setActionHandler @@ -8960,14 +8963,15 @@ /en-US/docs/Web/API/MediaStreamTrack.kind /en-US/docs/Web/API/MediaStreamTrack/kind /en-US/docs/Web/API/MediaStreamTrack.label /en-US/docs/Web/API/MediaStreamTrack/label /en-US/docs/Web/API/MediaStreamTrack.onmute /en-US/docs/Web/API/MediaStreamTrack/mute_event -/en-US/docs/Web/API/MediaStreamTrack.onoverconstrained /en-US/docs/Web/API/MediaStreamTrack/overconstrained_event +/en-US/docs/Web/API/MediaStreamTrack.onoverconstrained /en-US/docs/Web/API/MediaStreamTrack /en-US/docs/Web/API/MediaStreamTrack.onunmute /en-US/docs/Web/API/MediaStreamTrack/unmute_event /en-US/docs/Web/API/MediaStreamTrack.readyState /en-US/docs/Web/API/MediaStreamTrack/readyState /en-US/docs/Web/API/MediaStreamTrack.stop /en-US/docs/Web/API/MediaStreamTrack/stop /en-US/docs/Web/API/MediaStreamTrack/onended /en-US/docs/Web/API/MediaStreamTrack/ended_event /en-US/docs/Web/API/MediaStreamTrack/onmute /en-US/docs/Web/API/MediaStreamTrack/mute_event -/en-US/docs/Web/API/MediaStreamTrack/onoverconstrained /en-US/docs/Web/API/MediaStreamTrack/overconstrained_event +/en-US/docs/Web/API/MediaStreamTrack/onoverconstrained /en-US/docs/Web/API/MediaStreamTrack /en-US/docs/Web/API/MediaStreamTrack/onunmute /en-US/docs/Web/API/MediaStreamTrack/unmute_event +/en-US/docs/Web/API/MediaStreamTrack/overconstrained_event /en-US/docs/Web/API/MediaStreamTrack /en-US/docs/Web/API/MediaStreamTrack/remote /en-US/docs/Web/API/MediaStreamTrack /en-US/docs/Web/API/MediaStreamTrackAudioSourceOptions /en-US/docs/Web/API/MediaStreamTrackAudioSourceNode /en-US/docs/Web/API/MediaStreamTrackAudioSourceOptions/mediaStreamTrack /en-US/docs/Web/API/MediaStreamTrackAudioSourceNode @@ -9604,7 +9608,7 @@ /en-US/docs/Web/API/SVGElement/oncontextmenu /en-US/docs/Web/API/Element/contextmenu_event /en-US/docs/Web/API/SVGElement/ondblclick /en-US/docs/Web/API/Element/dblclick_event /en-US/docs/Web/API/SVGElement/onfocus /en-US/docs/Web/API/Window/focus_event -/en-US/docs/Web/API/SVGElement/oninput /en-US/docs/Web/API/HTMLElement/input_event +/en-US/docs/Web/API/SVGElement/oninput /en-US/docs/Web/API/Element/input_event /en-US/docs/Web/API/SVGElement/onkeydown /en-US/docs/Web/API/Element/keydown_event /en-US/docs/Web/API/SVGElement/onkeypress /en-US/docs/Web/API/Element/keypress_event /en-US/docs/Web/API/SVGElement/onkeyup /en-US/docs/Web/API/Element/keyup_event @@ -10062,6 +10066,7 @@ /en-US/docs/Web/API/WebRTC_API/Architecture /en-US/docs/Web/API/WebRTC_API/Protocols /en-US/docs/Web/API/WebRTC_API/Architecture/Connectivity /en-US/docs/Web/API/WebRTC_API/Connectivity /en-US/docs/Web/API/WebRTC_API/Architecture/Protocols /en-US/docs/Web/API/WebRTC_API/Protocols +/en-US/docs/Web/API/WebRTC_API/High-level_guide /en-US/docs/Web/API/WebRTC_API /en-US/docs/Web/API/WebRTC_API/Interface_overview /en-US/docs/Web/API/WebRTC_API#WebRTC_concepts_and_usage /en-US/docs/Web/API/WebRTC_API/Introduction /en-US/docs/Web/API/WebRTC_API /en-US/docs/Web/API/WebRTC_API/Overview /en-US/docs/Web/API/WebRTC_API#WebRTC_concepts_and_usage @@ -10771,7 +10776,6 @@ /en-US/docs/Web/API/window.content /en-US/docs/Web/API/Window /en-US/docs/Web/API/window.crypto /en-US/docs/Web/API/crypto_property /en-US/docs/Web/API/window.crypto.getRandomValues /en-US/docs/Web/API/Crypto/getRandomValues -/en-US/docs/Web/API/window.defaultStatus /en-US/docs/Web/API/Window/defaultStatus /en-US/docs/Web/API/window.document /en-US/docs/Web/API/Window/document /en-US/docs/Web/API/window.dump /en-US/docs/Web/API/Window/dump /en-US/docs/Web/API/window.escape /en-US/docs/Web/JavaScript/Reference/Global_Objects/escape @@ -10848,7 +10852,7 @@ /en-US/docs/Web/API/window.onerror /en-US/docs/Web/API/Window/error_event /en-US/docs/Web/API/window.onfocus /en-US/docs/Web/API/Window/focus_event /en-US/docs/Web/API/window.onhashchange /en-US/docs/Web/API/Window/hashchange_event -/en-US/docs/Web/API/window.oninput /en-US/docs/Web/API/HTMLElement/input_event +/en-US/docs/Web/API/window.oninput /en-US/docs/Web/API/Element/input_event /en-US/docs/Web/API/window.onkeydown /en-US/docs/Web/API/Element/keydown_event /en-US/docs/Web/API/window.onkeypress /en-US/docs/Web/API/Element/keypress_event /en-US/docs/Web/API/window.onkeyup /en-US/docs/Web/API/Element/keyup_event @@ -11329,6 +11333,7 @@ /en-US/docs/Web/CSS/::-ms-browse /en-US/docs/Web/CSS/::file-selector-button /en-US/docs/Web/CSS/::-webkit-file-upload-button /en-US/docs/Web/CSS/::file-selector-button /en-US/docs/Web/CSS/::-webkit-input-placeholder /en-US/docs/Web/CSS/::placeholder +/en-US/docs/Web/CSS/::-webkit-outer-spin-button /en-US/docs/Web/CSS/::-webkit-inner-spin-button /en-US/docs/Web/CSS/::-webkit-resizer /en-US/docs/Web/CSS/::-webkit-scrollbar /en-US/docs/Web/CSS/::-webkit-scrollbar-button /en-US/docs/Web/CSS/::-webkit-scrollbar /en-US/docs/Web/CSS/::-webkit-scrollbar-corner /en-US/docs/Web/CSS/::-webkit-scrollbar @@ -11375,7 +11380,7 @@ /en-US/docs/Web/CSS/Alias /en-US/docs/Web/CSS/cursor /en-US/docs/Web/CSS/All_About_The_Containing_Block /en-US/docs/Web/CSS/Containing_block /en-US/docs/Web/CSS/Aural /en-US/docs/Web/CSS/@media/aural -/en-US/docs/Web/CSS/Block_formatting_context /en-US/docs/Web/Guide/CSS/Block_formatting_context +/en-US/docs/Web/CSS/Block_formatting_context /en-US/docs/Web/CSS/CSS_display/Block_formatting_context /en-US/docs/Web/CSS/CSS3_Columns /en-US/docs/Web/CSS/CSS_multicol_layout/Using_multicol_layouts /en-US/docs/Web/CSS/CSS_Background_and_Borders /en-US/docs/Web/CSS/CSS_backgrounds_and_borders /en-US/docs/Web/CSS/CSS_Background_and_Borders/Border-image_generator /en-US/docs/Web/CSS/CSS_backgrounds_and_borders/Border-image_generator @@ -11401,10 +11406,10 @@ /en-US/docs/Web/CSS/CSS_Columns/Using_multicol_layouts /en-US/docs/Web/CSS/CSS_multicol_layout/Using_multicol_layouts /en-US/docs/Web/CSS/CSS_Device_Adaptation /en-US/docs/Web/CSS /en-US/docs/Web/CSS/CSS_Device_Adaptation/Viewport_Concepts /en-US/docs/Web/CSS/Viewport_concepts -/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Advanced_layouts_with_flexbox /en-US/docs/Web/CSS/CSS_flexible_box_layout/Backwards_compatibility_of_flexbox +/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Advanced_layouts_with_flexbox /en-US/docs/Glossary/Flexbox /en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Box_Alignment_in_Flexbox /en-US/docs/Web/CSS/CSS_box_alignment/Box_alignment_in_flexbox /en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Controlling_Ratios_of_Flex_Items_Along_the_Main_Ax /en-US/docs/Web/CSS/CSS_flexible_box_layout/Controlling_ratios_of_flex_items_along_the_main_axis -/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Mixins /en-US/docs/Web/CSS/CSS_flexible_box_layout/Backwards_compatibility_of_flexbox +/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Mixins /en-US/docs/Glossary/Flexbox /en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes /en-US/docs/Web/CSS/CSS_flexible_box_layout/Basic_concepts_of_flexbox /en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Using_flexbox_to_lay_out_web_applications /en-US/docs/Web/CSS/CSS_flexible_box_layout/Typical_use_cases_of_flexbox /en-US/docs/Web/CSS/CSS_Flow_Layout/Formatting_Contexts_Explained /en-US/docs/Web/CSS/CSS_flow_layout/Introduction_to_formatting_contexts @@ -11475,8 +11480,11 @@ /en-US/docs/Web/CSS/CSS_User_Interface /en-US/docs/Web/CSS/CSS_basic_user_interface /en-US/docs/Web/CSS/CSS_Variables /en-US/docs/Web/CSS/CSS_cascading_variables /en-US/docs/Web/CSS/CSS_Viewport /en-US/docs/Web/CSS +/en-US/docs/Web/CSS/CSS_charsets /en-US/docs/Web/CSS/CSS_syntax +/en-US/docs/Web/CSS/CSS_container_queries /en-US/docs/Web/CSS/CSS_containment/Container_queries /en-US/docs/Web/CSS/CSS_descriptor_definition /en-US/docs/Web/CSS /en-US/docs/Web/CSS/CSS_flex-wrap /en-US/docs/Web/CSS/flex-wrap +/en-US/docs/Web/CSS/CSS_flexible_box_layout/Backwards_compatibility_of_flexbox /en-US/docs/Glossary/Flexbox /en-US/docs/Web/CSS/CSS_grid_layout/Layout_using_line-based_placement /en-US/docs/Web/CSS/CSS_grid_layout/Grid_layout_using_line-based_placement /en-US/docs/Web/CSS/CSS_grid_layout/Layout_using_named_grid_lines /en-US/docs/Web/CSS/CSS_grid_layout/Grid_layout_using_named_grid_lines /en-US/docs/Web/CSS/CSS_percentage_values /en-US/docs/Web/CSS @@ -11547,7 +11555,6 @@ /en-US/docs/Web/CSS/calc() /en-US/docs/Web/CSS/calc /en-US/docs/Web/CSS/clamp() /en-US/docs/Web/CSS/clamp /en-US/docs/Web/CSS/color-adjust /en-US/docs/Web/CSS/print-color-adjust -/en-US/docs/Web/CSS/color-interpolation /en-US/docs/Web/SVG/Attribute/color-interpolation /en-US/docs/Web/CSS/color-interpolation-filters /en-US/docs/Web/SVG/Attribute/color-interpolation-filters /en-US/docs/Web/CSS/color_value/color() /en-US/docs/Web/CSS/color_value/color /en-US/docs/Web/CSS/color_value/color-contrast() /en-US/docs/Web/CSS/color_value/color-contrast @@ -11671,7 +11678,7 @@ /en-US/docs/Web/CSS/repeating-linear-gradient() /en-US/docs/Web/CSS/gradient/repeating-linear-gradient /en-US/docs/Web/CSS/repeating-radial-gradient /en-US/docs/Web/CSS/gradient/repeating-radial-gradient /en-US/docs/Web/CSS/repeating-radial-gradient() /en-US/docs/Web/CSS/gradient/repeating-radial-gradient -/en-US/docs/Web/CSS/rgb /en-US/docs/Web/CSS/color_value#rgb()_and_rgba() +/en-US/docs/Web/CSS/rgb /en-US/docs/Web/CSS/color_value/rgb /en-US/docs/Web/CSS/scroll /en-US/docs/Web/CSS/overflow /en-US/docs/Web/CSS/scrollbar-track-color /en-US/docs/Web/CSS/scrollbar-color /en-US/docs/Web/CSS/shape-box /en-US/docs/Web/CSS/shape-outside @@ -11759,7 +11766,7 @@ /en-US/docs/Web/Events/audioprocess /en-US/docs/Web/API/ScriptProcessorNode/audioprocess_event /en-US/docs/Web/Events/audiostart /en-US/docs/Web/API/SpeechRecognition/audiostart_event /en-US/docs/Web/Events/auxclick /en-US/docs/Web/API/Element/auxclick_event -/en-US/docs/Web/Events/beforeinput /en-US/docs/Web/API/HTMLElement/beforeinput_event +/en-US/docs/Web/Events/beforeinput /en-US/docs/Web/API/Element/beforeinput_event /en-US/docs/Web/Events/beforeprint /en-US/docs/Web/API/Window/beforeprint_event /en-US/docs/Web/Events/beforescriptexecute /en-US/docs/Web/API/Element/beforescriptexecute_event /en-US/docs/Web/Events/beforeunload /en-US/docs/Web/API/Window/beforeunload_event @@ -11838,7 +11845,7 @@ /en-US/docs/Web/Events/iceconnectionstatechange /en-US/docs/Web/API/RTCPeerConnection/iceconnectionstatechange_event /en-US/docs/Web/Events/icegatheringstatechange /en-US/docs/Web/API/RTCPeerConnection/icegatheringstatechange_event /en-US/docs/Web/Events/icegatheringstatechange_event /en-US/docs/Web/API/RTCPeerConnection/icegatheringstatechange_event -/en-US/docs/Web/Events/input /en-US/docs/Web/API/HTMLElement/input_event +/en-US/docs/Web/Events/input /en-US/docs/Web/API/Element/input_event /en-US/docs/Web/Events/install /en-US/docs/Web/API/Window/appinstalled_event /en-US/docs/Web/Events/invalid /en-US/docs/Web/API/HTMLInputElement/invalid_event /en-US/docs/Web/Events/keydown /en-US/docs/Web/API/Element/keydown_event @@ -12027,6 +12034,7 @@ /en-US/docs/Web/Guide/Audio_and_video_delivery/cross_browser_video_player /en-US/docs/Web/Media/Audio_and_video_delivery/cross_browser_video_player /en-US/docs/Web/Guide/Audio_and_video_manipulation /en-US/docs/Web/Media/Audio_and_video_manipulation /en-US/docs/Web/Guide/CSS /en-US/docs/Learn/CSS +/en-US/docs/Web/Guide/CSS/Block_formatting_context /en-US/docs/Web/CSS/CSS_display/Block_formatting_context /en-US/docs/Web/Guide/CSS/CSS_Image_Sprites /en-US/docs/Web/CSS/CSS_images/Implementing_image_sprites_in_CSS /en-US/docs/Web/Guide/CSS/Consistent_list_indentation /en-US/docs/Web/CSS/CSS_lists/Consistent_list_indentation /en-US/docs/Web/Guide/CSS/Counters /en-US/docs/Web/CSS/CSS_counter_styles/Using_CSS_counters @@ -12157,8 +12165,12 @@ /en-US/docs/Web/Guide/HTML/Using_HTML_sections_and_outlines /en-US/docs/Web/HTML/Element/Heading_Elements /en-US/docs/Web/Guide/HTML/Using_data_attributes /en-US/docs/Learn/HTML/Howto/Use_data_attributes /en-US/docs/Web/Guide/HTML/XHTML /en-US/docs/Glossary/XHTML +/en-US/docs/Web/Guide/Houdini /en-US/docs/Web/API/Houdini_APIs /en-US/docs/Web/Guide/Index /en-US/docs/Web/Guide /en-US/docs/Web/Guide/Introduction_to_Web_development /en-US/docs/Learn +/en-US/docs/Web/Guide/Mobile /en-US/docs/Learn/CSS/CSS_layout/Responsive_Design +/en-US/docs/Web/Guide/Mobile/A_hybrid_approach /en-US/docs/Learn/CSS/CSS_layout/Responsive_Design +/en-US/docs/Web/Guide/Mobile/Mobile-friendliness /en-US/docs/Learn/CSS/CSS_layout/Responsive_Design /en-US/docs/Web/Guide/Mobile/Separate_sites /en-US/docs/Web/Progressive_web_apps /en-US/docs/Web/Guide/Needs_categorization/Functions_available_to_workers /en-US/docs/Web/API/Web_Workers_API/Functions_and_classes_available_to_workers /en-US/docs/Web/Guide/Parsing_and_serializing_XML /en-US/docs/Web/XML/Parsing_and_serializing_XML @@ -12333,7 +12345,7 @@ /en-US/docs/Web/HTTP/X-Frame-Options /en-US/docs/Web/HTTP/Headers/X-Frame-Options /en-US/docs/Web/HTTP/data_URIs /en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs /en-US/docs/Web/HTTP/www_and_non-www_URLs /en-US/docs/Web/HTTP/Basics_of_HTTP/Choosing_between_www_and_non-www_URLs -/en-US/docs/Web/Houdini /en-US/docs/Web/Guide/Houdini +/en-US/docs/Web/Houdini /en-US/docs/Web/API/Houdini_APIs /en-US/docs/Web/Houdini/CSS_Painting_API /en-US/docs/Web/API/CSS_Painting_API/Guide /en-US/docs/Web/Houdini/CSS_Typed_OM /en-US/docs/Web/API/CSS_Typed_OM_API /en-US/docs/Web/Houdini/Learn/CSS_Painting_API /en-US/docs/Web/API/CSS_Painting_API/Guide @@ -12870,7 +12882,7 @@ /en-US/docs/Web/Reference/Events/gamepadconnected /en-US/docs/Web/API/Window/gamepadconnected_event /en-US/docs/Web/Reference/Events/gamepaddisconnected /en-US/docs/Web/API/Window/gamepaddisconnected_event /en-US/docs/Web/Reference/Events/hashchange /en-US/docs/Web/API/Window/hashchange_event -/en-US/docs/Web/Reference/Events/input /en-US/docs/Web/API/HTMLElement/input_event +/en-US/docs/Web/Reference/Events/input /en-US/docs/Web/API/Element/input_event /en-US/docs/Web/Reference/Events/invalid /en-US/docs/Web/API/HTMLInputElement/invalid_event /en-US/docs/Web/Reference/Events/keydown /en-US/docs/Web/API/Element/keydown_event /en-US/docs/Web/Reference/Events/keypress /en-US/docs/Web/API/Element/keypress_event @@ -13180,9 +13192,9 @@ /en-US/docs/Web_Development /en-US/docs/Web/Guide /en-US/docs/Web_Development/HTTP_cookies /en-US/docs/Web/HTTP/Cookies /en-US/docs/Web_Development/Introduction_to_Web_development /en-US/docs/Learn -/en-US/docs/Web_Development/Mobile /en-US/docs/Web/Guide/Mobile -/en-US/docs/Web_Development/Mobile/A_hybrid_approach /en-US/docs/Web/Guide/Mobile/A_hybrid_approach -/en-US/docs/Web_Development/Mobile/Mobile-friendliness /en-US/docs/Web/Guide/Mobile/Mobile-friendliness +/en-US/docs/Web_Development/Mobile /en-US/docs/Learn/CSS/CSS_layout/Responsive_Design +/en-US/docs/Web_Development/Mobile/A_hybrid_approach /en-US/docs/Learn/CSS/CSS_layout/Responsive_Design +/en-US/docs/Web_Development/Mobile/Mobile-friendliness /en-US/docs/Learn/CSS/CSS_layout/Responsive_Design /en-US/docs/Web_Development/Mobile/Responsive_design /en-US/docs/Web/Progressive_web_apps /en-US/docs/Web_Development/Mobile/Responsive_design/Responsive_design_references /en-US/docs/Web/Progressive_web_apps /en-US/docs/Web_Development/Mobile/Separate_sites /en-US/docs/Glossary/Responsive_web_design @@ -13686,7 +13698,6 @@ /en-US/docs/window.closed /en-US/docs/Web/API/Window/closed /en-US/docs/window.confirm /en-US/docs/Web/API/Window/confirm /en-US/docs/window.crypto /en-US/docs/Web/API/crypto_property -/en-US/docs/window.defaultStatus /en-US/docs/Web/API/Window/defaultStatus /en-US/docs/window.document /en-US/docs/Web/API/Window/document /en-US/docs/window.dump /en-US/docs/Web/API/Window/dump /en-US/docs/window.escape /en-US/docs/Web/JavaScript/Reference/Global_Objects/escape diff --git a/files/en-us/_wikihistory.json b/files/en-us/_wikihistory.json index 60db8e73468ec21..4d356f42503af97 100644 --- a/files/en-us/_wikihistory.json +++ b/files/en-us/_wikihistory.json @@ -11697,43 +11697,6 @@ "groovecoder" ] }, - "MDN/Contribute": { - "modified": "2020-12-14T09:31:17.213Z", - "contributors": [ - "sourabhramsingh", - "maxTarlov", - "chrisdavidmills", - "aditibasu", - "wbamberg", - "SphinxKnight", - "shwetabhsuman", - "jswisher", - "wdot789", - "fotografi", - "Sheppy", - "vikash111", - "Kerstomaat", - "ertogrul", - "elwakil", - "Thomskii", - "Lasantha", - "jsx", - "saifulislam1", - "adi28galaxyak", - "Volluta", - "Husaria", - "klez", - "pytseng", - "alispivak", - "utente-pc", - "emmanuelodenyire", - "Mars" - ] - }, - "MDN/Contribute/Processes": { - "modified": "2020-09-30T15:17:09.733Z", - "contributors": ["wbamberg", "david_ross", "jswisher", "Sheppy"] - }, "MDN/MDN_Product_Advisory_Board": { "modified": "2019-06-05T12:41:23.682Z", "contributors": [ @@ -12954,10 +12917,6 @@ "aswan" ] }, - "Mozilla/Add-ons/WebExtensions/API/downloads/drag": { - "modified": "2020-10-15T21:44:35.541Z", - "contributors": ["wbamberg", "Makyen", "chrisdavidmills"] - }, "Mozilla/Add-ons/WebExtensions/API/downloads/erase": { "modified": "2020-10-15T21:44:38.278Z", "contributors": ["wbamberg", "Makyen", "chrisdavidmills"] @@ -29268,10 +29227,6 @@ "JesseW" ] }, - "Web/API/Document/lostpointercapture_event": { - "modified": "2020-10-15T22:14:52.161Z", - "contributors": ["Clarkkkk", "mfuji09", "wbamberg"] - }, "Web/API/Document/mozSetImageElement": { "modified": "2020-10-15T21:13:49.622Z", "contributors": [ @@ -31021,6 +30976,17 @@ "jpmedley" ] }, + "Web/API/Element/beforeinput_event": { + "modified": "2020-11-11T09:54:44.715Z", + "contributors": [ + "Rumyra", + "chrisdavidmills", + "mfuji09", + "Sheppy", + "Watilin", + "mfluehr" + ] + }, "Web/API/Element/beforescriptexecute_event": { "modified": "2020-10-15T21:19:30.700Z", "contributors": [ @@ -32211,6 +32177,46 @@ "JesseW" ] }, + "Web/API/Element/input_event": { + "modified": "2020-10-15T21:19:24.780Z", + "contributors": [ + "mfuji09", + "dienluong", + "chrisdavidmills", + "estelle", + "Sheppy", + "wbamberg", + "mfluehr", + "matijs", + "JLHwung", + "Majr", + "fscholz", + "thatemil", + "roryokane", + "lsolova", + "jchen", + "ibmua", + "jkoritzinsky", + "erikadoyle", + "r-o-b", + "cvrebert", + "Sebastianz", + "chrisAnderson", + "teoli", + "jonkoops", + "claudepache", + "mkato", + "Masayuki", + "bending_the_rules", + "codepo8", + "jimmont", + "joeldart", + "Nickolay", + "parthiv", + "louisremi", + "ethertank" + ] + }, "Web/API/Element/insertAdjacentElement": { "modified": "2020-10-17T17:01:56.118Z", "contributors": [ @@ -37950,15 +37956,16 @@ "Krinkle" ] }, - "Web/API/HTMLElement/beforeinput_event": { - "modified": "2020-11-11T09:54:44.715Z", + "Web/API/HTMLElement/autofocus": { + "modified": "2020-10-15T21:42:28.924Z", "contributors": [ - "Rumyra", - "chrisdavidmills", - "mfuji09", - "Sheppy", - "Watilin", - "mfluehr" + "nali", + "sideshowbarker", + "connorshea", + "libbymc", + "Druzion", + "teoli", + "Rakhisharma" ] }, "Web/API/HTMLElement/blur": { @@ -38288,46 +38295,6 @@ "evilpie" ] }, - "Web/API/HTMLElement/input_event": { - "modified": "2020-10-15T21:19:24.780Z", - "contributors": [ - "mfuji09", - "dienluong", - "chrisdavidmills", - "estelle", - "Sheppy", - "wbamberg", - "mfluehr", - "matijs", - "JLHwung", - "Majr", - "fscholz", - "thatemil", - "roryokane", - "lsolova", - "jchen", - "ibmua", - "jkoritzinsky", - "erikadoyle", - "r-o-b", - "cvrebert", - "Sebastianz", - "chrisAnderson", - "teoli", - "jonkoops", - "claudepache", - "mkato", - "Masayuki", - "bending_the_rules", - "codepo8", - "jimmont", - "joeldart", - "Nickolay", - "parthiv", - "louisremi", - "ethertank" - ] - }, "Web/API/HTMLElement/isContentEditable": { "modified": "2020-10-15T21:12:52.957Z", "contributors": [ @@ -40835,18 +40802,6 @@ "teoli" ] }, - "Web/API/HTMLSelectElement/autofocus": { - "modified": "2020-10-15T21:42:28.924Z", - "contributors": [ - "nali", - "sideshowbarker", - "connorshea", - "libbymc", - "Druzion", - "teoli", - "Rakhisharma" - ] - }, "Web/API/HTMLSelectElement/checkValidity": { "modified": "2020-10-15T21:29:52.800Z", "contributors": [ @@ -42348,6 +42303,18 @@ "modified": "2019-03-18T20:56:26.488Z", "contributors": ["wbamberg", "chrisdavidmills", "rugk"] }, + "Web/API/Houdini_APIs": { + "modified": "2020-07-16T03:51:08.991Z", + "contributors": [ + "Wind1808", + "enva-2-7-1-2", + "estelle", + "chrisdavidmills", + "SphinxKnight", + "jason2477", + "Sheppy" + ] + }, "Web/API/IDBCursor": { "modified": "2020-10-15T21:09:31.954Z", "contributors": [ @@ -43075,16 +43042,6 @@ "chrisdavidmills" ] }, - "Web/API/IDBLocaleAwareKeyRange": { - "modified": "2020-10-15T21:38:45.838Z", - "contributors": [ - "teoli", - "fscholz", - "Sebastianz", - "Seta00", - "chrisdavidmills" - ] - }, "Web/API/IDBObjectStore": { "modified": "2020-10-15T21:10:03.883Z", "contributors": [ @@ -45836,20 +45793,6 @@ "modified": "2020-10-15T21:51:07.748Z", "contributors": ["fscholz", "david_ross", "jpmedley"] }, - "Web/API/MediaRecorder/warning_event": { - "modified": "2020-10-15T21:27:43.833Z", - "contributors": [ - "Sheppy", - "sideshowbarker", - "lucian95", - "miguelao", - "jpmedley", - "Sebastianz", - "chrisdavidmills", - "teoli", - "kscarfone" - ] - }, "Web/API/MediaRecorderErrorEvent": { "modified": "2020-10-15T21:57:11.850Z", "contributors": ["sideshowbarker", "Sheppy"] @@ -46302,16 +46245,6 @@ "jpmedley" ] }, - "Web/API/MediaStreamTrack/overconstrained_event": { - "modified": "2020-10-15T21:29:32.712Z", - "contributors": [ - "alattalatta", - "sideshowbarker", - "fscholz", - "libbymc", - "teoli" - ] - }, "Web/API/MediaStreamTrack/readyState": { "modified": "2020-10-15T21:29:36.532Z", "contributors": [ @@ -50553,19 +50486,6 @@ "SignpostMarv" ] }, - "Web/API/NotifyAudioAvailableEvent": { - "modified": "2019-03-24T00:05:46.158Z", - "contributors": [ - "Sheppy", - "alsntjsu", - "fscholz", - "teoli", - "kscarfone", - "ethertank", - "jswisher", - "sebmozilla" - ] - }, "Web/API/OES_element_index_uint": { "modified": "2020-10-15T21:43:51.807Z", "contributors": ["fscholz", "nmve", "teoli"] @@ -65026,10 +64946,6 @@ "chrisdavidmills" ] }, - "Web/API/WebRTC_API/High-level_guide": { - "modified": "2019-03-23T22:47:43.736Z", - "contributors": ["Sheppy"] - }, "Web/API/WebRTC_API/Intro_to_RTP": { "modified": "2019-03-18T21:41:44.636Z", "contributors": ["Sheppy"] @@ -66811,24 +66727,6 @@ "modified": "2020-10-15T22:16:14.635Z", "contributors": ["mfuji09", "wbamberg"] }, - "Web/API/Window/defaultStatus": { - "modified": "2019-04-05T17:00:29.943Z", - "contributors": [ - "Loirooriol", - "sarafec", - "fscholz", - "teoli", - "kscarfone", - "kohei.yoshino", - "Sheppy", - "feltronzach", - "Matej Lednar", - "Mgjbot", - "Dria", - "Callek", - "JesseW" - ] - }, "Web/API/Window/devicePixelRatio": { "modified": "2020-10-15T21:28:17.748Z", "contributors": [ @@ -72712,19 +72610,6 @@ "peterbraden" ] }, - "Web/Accessibility/Architecture": { - "modified": "2019-03-24T00:11:44.656Z", - "contributors": [ - "Sheppy", - "fscholz", - "badrfoot", - "Aaronlev", - "Joanmarie", - "Parente", - "Rd4Uix", - "Nickolay" - ] - }, "Web/Accessibility/Cognitive_accessibility": { "modified": "2019-11-18T16:53:41.344Z", "contributors": ["Igor-Sangin", "ericwbailey", "estelle", "jswisher"] @@ -73813,18 +73698,6 @@ "yusufgulled" ] }, - "Web/CSS/::-webkit-outer-spin-button": { - "modified": "2020-10-15T21:48:38.043Z", - "contributors": [ - "Sheppy", - "wbamberg", - "fscholz", - "teoli", - "mfluehr", - "Sebastianz", - "AjayPoshak" - ] - }, "Web/CSS/::-webkit-progress-bar": { "modified": "2020-10-15T21:41:33.061Z", "contributors": [ @@ -77125,10 +76998,6 @@ "modified": "2020-07-07T12:03:44.891Z", "contributors": ["wbamberg", "mfluehr"] }, - "Web/CSS/CSS_charsets": { - "modified": "2020-10-15T21:38:35.251Z", - "contributors": ["wbamberg", "fscholz", "mfluehr", "Sebastianz", "teoli"] - }, "Web/CSS/CSS_colors": { "modified": "2020-12-02T11:04:05.642Z", "contributors": ["peterbe", "wbamberg", "fscholz", "Sheppy", "mfluehr"] @@ -77258,6 +77127,43 @@ "teoli" ] }, + "Web/CSS/CSS_display/Block_formatting_context": { + "modified": "2020-11-02T20:53:20.927Z", + "contributors": [ + "spollard", + "pacexy", + "wbamberg", + "Mookiepiece", + "SelenIT", + "TrevorKarjanis", + "mfuji09", + "Konrud", + "estelle", + "wavesheep", + "jennyevans", + "MelvinIdema", + "chrisdavidmills", + "Ende93", + "xiaohanyu", + "YvonneZhang", + "pythonista27", + "S-Dey", + "mfluehr", + "yisibl", + "alberts+", + "rainyLeo", + "PageYe", + "HashemQolami", + "Jeremie", + "teoli", + "kscarfone", + "tregagnon", + "Sheppy", + "cbiesinger", + "Kohei", + "DBaron" + ] + }, "Web/CSS/CSS_filter_effects": { "modified": "2020-12-02T11:05:43.361Z", "contributors": ["peterbe", "wbamberg", "fscholz", "mfluehr"] @@ -77295,17 +77201,6 @@ "chrisdavidmills" ] }, - "Web/CSS/CSS_flexible_box_layout/Backwards_compatibility_of_flexbox": { - "modified": "2020-07-07T12:06:44.348Z", - "contributors": [ - "wbamberg", - "ExE-Boss", - "mattbrundageMDN", - "roryokane", - "chrisdavidmills", - "rachelandrew" - ] - }, "Web/CSS/CSS_flexible_box_layout/Basic_concepts_of_flexbox": { "modified": "2020-12-11T09:00:07.056Z", "contributors": [ @@ -78501,6 +78396,10 @@ "modified": "2020-04-27T22:31:21.929Z", "contributors": ["ExE-Boss", "mfuji09", "rachelandrew"] }, + "Web/CSS/CSS_syntax": { + "modified": "2020-10-15T21:38:35.251Z", + "contributors": ["wbamberg", "fscholz", "mfluehr", "Sebastianz", "teoli"] + }, "Web/CSS/CSS_table": { "modified": "2020-07-07T12:26:58.542Z", "contributors": ["wbamberg", "fscholz", "mfluehr", "Sebastianz", "teoli"] @@ -92068,43 +91967,6 @@ "ethertank" ] }, - "Web/Guide/CSS/Block_formatting_context": { - "modified": "2020-11-02T20:53:20.927Z", - "contributors": [ - "spollard", - "pacexy", - "wbamberg", - "Mookiepiece", - "SelenIT", - "TrevorKarjanis", - "mfuji09", - "Konrud", - "estelle", - "wavesheep", - "jennyevans", - "MelvinIdema", - "chrisdavidmills", - "Ende93", - "xiaohanyu", - "YvonneZhang", - "pythonista27", - "S-Dey", - "mfluehr", - "yisibl", - "alberts+", - "rainyLeo", - "PageYe", - "HashemQolami", - "Jeremie", - "teoli", - "kscarfone", - "tregagnon", - "Sheppy", - "cbiesinger", - "Kohei", - "DBaron" - ] - }, "Web/Guide/CSS/Getting_started/Challenge_solutions": { "modified": "2019-08-29T20:48:33.765Z", "contributors": [ @@ -92117,54 +91979,6 @@ "jswisher" ] }, - "Web/Guide/Houdini": { - "modified": "2020-07-16T03:51:08.991Z", - "contributors": [ - "Wind1808", - "enva-2-7-1-2", - "estelle", - "chrisdavidmills", - "SphinxKnight", - "jason2477", - "Sheppy" - ] - }, - "Web/Guide/Mobile": { - "modified": "2020-03-07T14:19:21.961Z", - "contributors": [ - "mfuji09", - "xfq", - "Zui", - "Andrew_Pfeiffer", - "Jeremie", - "Sheppy", - "wbamberg" - ] - }, - "Web/Guide/Mobile/A_hybrid_approach": { - "modified": "2019-03-24T00:12:25.721Z", - "contributors": [ - "rafrex", - "teoli", - "BenB", - "skimpax", - "trevorh", - "caos30", - "kohei.yoshino", - "jswisher" - ] - }, - "Web/Guide/Mobile/Mobile-friendliness": { - "modified": "2019-03-24T00:12:20.411Z", - "contributors": [ - "teoli", - "BenB", - "skimpax", - "kohei.yoshino", - "wbamberg", - "jswisher" - ] - }, "Web/Guide/Parsing_and_serializing_XML": { "modified": "2020-09-09T05:19:22.895Z", "contributors": [ @@ -124185,14 +123999,6 @@ "modified": "2020-10-15T21:04:59.286Z", "contributors": ["Sebastianz", "connorshea", "Jeremie"] }, - "Web/SVG/Attribute/contentScriptType": { - "modified": "2020-10-15T21:09:10.002Z", - "contributors": ["Sebastianz", "Jeremie"] - }, - "Web/SVG/Attribute/contentStyleType": { - "modified": "2020-10-15T21:09:14.670Z", - "contributors": ["Sebastianz", "George8211", "Jeremie", "pa7"] - }, "Web/SVG/Attribute/cursor": { "modified": "2020-10-15T21:18:37.523Z", "contributors": [ @@ -124406,16 +124212,6 @@ "Jeremie" ] }, - "Web/SVG/Attribute/filterRes": { - "modified": "2020-10-15T21:19:12.262Z", - "contributors": [ - "bershanskiy", - "Sebastianz", - "ExE-Boss", - "jpmedley", - "Jeremie" - ] - }, "Web/SVG/Attribute/filterUnits": { "modified": "2020-10-15T21:08:01.201Z", "contributors": ["Sebastianz", "Jeremie"] @@ -125377,10 +125173,6 @@ "Mogglewump" ] }, - "Web/SVG/Attribute/viewTarget": { - "modified": "2020-10-15T22:18:25.792Z", - "contributors": ["Sebastianz"] - }, "Web/SVG/Attribute/visibility": { "modified": "2020-10-15T21:07:30.330Z", "contributors": [ diff --git a/files/en-us/games/index.md b/files/en-us/games/index.md index cdff6f5631c67ba..0138768f7e1db12 100644 --- a/files/en-us/games/index.md +++ b/files/en-us/games/index.md @@ -42,8 +42,6 @@ For a list of web game examples, see our list of [Tutorials](/en-US/docs/Games/T - : Weekly newsletter about HTML game development, sent every Friday. Contains the latest articles, tutorials, tools, and resources. - [HTML5 Game Engine](https://html5gameengine.com/) - : List of the most popular HTML game frameworks along with their rating, features and samples. -- [JSBreakouts](https://jsbreakouts.org/) - - : Compare JavaScript Breakout clones in different frameworks to help you choose the right one for you. - [Tuts+ Game Development](https://gamedevelopment.tutsplus.com/) - : Tutorials and articles about game development in general. - [HTML5 Gamedev Starter](https://html5devstarter.enclavegames.com/) diff --git a/files/en-us/games/introduction/index.md b/files/en-us/games/introduction/index.md index 385247eb4f9c60c..08e4827a978f3f0 100644 --- a/files/en-us/games/introduction/index.md +++ b/files/en-us/games/introduction/index.md @@ -95,6 +95,8 @@ As a game developer, whether you're an individual or a large game studio, you wa For the tech folks, let's dig into the APIs the Web brings to the table that cater to game developers. Here's a thorough list to give you a taste of what the Web can do for you: +- [Fetch API](/en-US/docs/Web/API/Fetch_API) + - : Send and receive any kind of data you want from a Web server like downloading new game levels and artwork to transmitting non-real-time game status information back and forth. - [Full Screen API](/en-US/docs/Web/API/Fullscreen_API) - : This simple API lets your game take over the entire screen, thereby immersing the player in action. - [Gamepad API](/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API) @@ -123,5 +125,3 @@ For the tech folks, let's dig into the APIs the Web brings to the table that cat - : The WebSocket API lets you connect your app or site to a server to transmit data back and forth in real-time. Perfect for multiplayer gaming action, chat services, and so forth. - [Web Workers](/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) - : Workers give you the ability to spawn background threads running their own JavaScript code, to take advantage of modern, multicore processors. -- [XMLHttpRequest](/en-US/docs/Web/API/XMLHttpRequest) and [File API](/en-US/docs/Web/API/File_and_Directory_Entries_API) - - : The combination of XMLHttpRequest and the File API lets you send and receive any kind of data you want (don't let the "XML" throw you!) from a Web server. This is a great way to do anything from downloading new game levels and artwork to transmitting non-real-time game status information back and forth. diff --git a/files/en-us/games/introduction_to_html5_game_development/index.md b/files/en-us/games/introduction_to_html5_game_development/index.md index fd118101b23864f..c46ec12547f4a6e 100644 --- a/files/en-us/games/introduction_to_html5_game_development/index.md +++ b/files/en-us/games/introduction_to_html5_game_development/index.md @@ -84,6 +84,8 @@ page-type: guide +- [Fetch API](/en-US/docs/Web/API/Fetch_API) + - : Send and receive any kind of data you want from a Web server like downloading new game levels and artwork to transmitting non-real-time game status information back and forth. - [Full Screen API](/en-US/docs/Web/API/Fullscreen_API) - : Full screen gameplay. - [Gamepad API](/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API) @@ -113,5 +115,3 @@ page-type: guide - : Connect your app or site to a server to transmit data back and forth in real-time. Perfect for multiplayer gaming action, chat services, and so forth. - [Web Workers](/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) - : Spawn background threads running their own JavaScript code for multicore processors. -- [XMLHttpRequest](/en-US/docs/Web/API/XMLHttpRequest) and [File API](/en-US/docs/Web/API/File_API) - - : Send and receive any kind of data you want from a Web server like downloading new game levels and artwork to transmitting non-real-time game status information back and forth. diff --git a/files/en-us/games/publishing_games/game_promotion/index.md b/files/en-us/games/publishing_games/game_promotion/index.md index d51d6e8f4efc47d..336de1afbca3567 100644 --- a/files/en-us/games/publishing_games/game_promotion/index.md +++ b/files/en-us/games/publishing_games/game_promotion/index.md @@ -24,33 +24,33 @@ While you can create your website from scratch, there are also tools that can he ## Social media -Your social media presence is very important — [hashtags](https://twitter.com/hashtag/gamedev) can help find friends and allow you to engage with the community and help other devs in need. Honesty is key and you should be authentic, because nobody likes boring press releases or pushy advertisements. When the time comes, your community will help you spread the word about your shiny new game! +Your social media presence is very important. The `#gamedev` hashtag can help find friends and allow you to engage with the community and help other devs in need. Honesty is key and you should be authentic; nobody likes boring press releases or pushy advertisements. When the time comes, your community will help you spread the word about your shiny new game! -Keep an eye on gamers who stream on YouTube and Twitch, engage with Twitter circles and be active on forums such as [HTML5GameDevs.com](https://www.html5gamedevs.com/). Share your news and answer questions so that people will value what you're doing and will know that you're trustworthy. Remember to not be too pushy when it comes to telling everyone about your games — you're not a walking advertisement. +Keep an eye on gamers who stream on YouTube and Twitch, and be active on forums such as [HTML5GameDevs.com](https://www.html5gamedevs.com/). Share your news and answer questions so that people will value what you're doing and will know that you're trustworthy. Remember to not be too pushy when it comes to telling everyone about your games — you're not a walking advertisement. Grow your audience by talking to them, sharing tips, offering discounts, giving away prizes in competitions, or just complaining at the weather or buggy browser you have to deal with. Be generous, be yourself and be there for others, and you'll be treated with respect. ## Game portals -Using game portals is mostly concerned with [monetization](/en-US/docs/Games/Publishing_games/Game_monetization), but if you're not planning to [sell licenses](/en-US/docs/Games/Publishing_games/Game_monetization#licensing) to allow people to purchase your game and are intending to [implement adverts](/en-US/docs/Games/Publishing_games/Game_monetization#advertisements) or in-app purchases instead, promoting your game across free portals can be effective. +Using game portals is mostly concerned with [monetization](/en-US/docs/Games/Publishing_games/Game_monetization), but if you're not planning to [sell licenses](/en-US/docs/Games/Publishing_games/Game_monetization#licensing) to allow people to purchase your game and intend to [implement adverts](/en-US/docs/Games/Publishing_games/Game_monetization#advertisements) or in-app purchases instead, promoting your game across free portals can be effective. -There are a number of different game portals to which you can send your games for publication. Some portals have their own APIs that allow you to authorize users, save their progress and process in-app purchases. You can also sell a full version of the game from inside your browser demo version, which will be a great move considering high competition, some developers even manage to make full browser versions. Most portals offer revenue share deals or will buy nonexclusive license. +There are a number of different game portals to which you can send your games for publication. Some portals have their own APIs that allow you to authorize users, save their progress and process in-app purchases. You can also sell a full version of the game from inside your browser demo version, which will be a great move considering high competition, some developers even manage to make full browser versions. Most portals offer revenue share deals or will buy nonexclusive licenses. -Free portals offer traffic, but only the best ones are popular enough to generate revenues from advertisements on in-app purchases. On the other hand they are a perfect tool to make games visible to a broader audience if you have no budget and limited time. +Free portals offer traffic, but only the best ones are popular enough to generate revenues from advertisements on in-app purchases. On the other hand, they are a perfect tool to make games visible to a broader audience if you have no budget and limited time. ## Press You can try and reach the [press](https://indiegamesplus.com/) about your game, but bear in mind that they get a tonne of requests like this every single day, so be humble and patient if they don't answer right away, and be polite when talking to them. Be sure to check first if they are dealing with specific genres of games or platforms, so you don't send them something that is not relevant to them in the first place. If you're honest with your approach and your game is good, then you've got more of a chance of success. -If you want to learn more about the etiquette of contacting the press you should definitely check out [How To Contact Press](https://app.box.com/s/p0ft5zdolpi0ydkrykab) - a great guide from Pixel Prospector. +If you want to learn more about the etiquette of contacting the press you should check out [How To Contact Press](https://app.box.com/s/p0ft5zdolpi0ydkrykab) - a great guide from Pixel Prospector. ## Tutorials -It's good to share your knowledge with other devs — after all you probably learned a thing or two from online articles, so you take the time to pay that knowledge forward. Talking or writing about something you achieved or problems you overcame is something people would be interested it. And you can use your own game as an example, especially in a tutorial when you're [showing how to do something you've implemented already](/en-US/docs/Games/Techniques/Controls_Gamepad_API). That way everyone benefits — people learn new skills, your game gets promoted, and if you're lucky you can even get paid for writing a tutorial if it's good enough. +It's good to share your knowledge with other devs — after all, you probably learned a thing or two from online articles, so you take the time to pay that knowledge forward. Talking or writing about something you achieved or problems you overcame is something people would be interested in. Also, you can use your own game as an example, especially in a tutorial when you're [showing how to do something you've implemented already](/en-US/docs/Games/Techniques/Controls_Gamepad_API). That way everyone benefits — people learn new skills, your game gets promoted, and if you're lucky you can even get paid for writing a tutorial if it's good enough. -There are portals like [Tuts+ Game Development](https://gamedevelopment.tutsplus.com/) which will be more than happy if you write for them - they pay for the content, but not all topic ideas will be accepted. When writing a tutorial remember to focus on delivering something valuable to the reader. They want to learn something - offer your expertise and use your game as a case study. Focus on one aspect and try to explain it throughout and in detail. Also remember to follow up discussion in comments if people have any questions. +There are portals like [Tuts+ Game Development](https://gamedevelopment.tutsplus.com/) which will be more than happy if you write for them - they pay for the content, but not all topic ideas will be accepted. When writing a tutorial remember to focus on delivering something valuable to the reader. They want to learn something - offer your expertise and use your game as a case study. Focus on one aspect and try to explain it throughout and in detail. Also, remember to follow up on discussions in your comments if people have any questions. -If portals you contact are not interested in your content because you don't have any experience yet, try writing tutorials and publish them on [your own blog](#website_and_blog) first. It's the easiest way to train your writing skills on your own. +If portals you contact are not interested in your content because you don't have any experience yet, try writing tutorials and then publish them on [your own blog](#website_and_blog) first. It's the easiest way to train your writing skills on your own. ## Events @@ -62,7 +62,7 @@ There are many conferences where you can give a talk explaining some technical d ### Fairs -The other event-related option is fairs (or expos) — at such an event you can get a booth among other devs and promote your game to all the attendees passing by. If you do so, try to be unique and original, so you easily stand from the crowd. Do it the right way and everybody will be talking about you and your game. Having a booth gives you the possibility to interact with your fans directly — besides the promotion part you can also test new builds of your game on regular people and fix any bugs (or incorporate any feedback) they uncover. You can't imagine what people may come up with when playing your game, and what obvious issues you've missed while spending hours polishing it. +The other event-related option is fairs (or expos) — at such an event you can get a booth among other devs and promote your game to all the attendees passing by. If you do so, try to be unique and original, so you easily stand out from the crowd. Do it the right way and everybody will be talking about you and your game. Having a booth gives you the possibility to interact with your fans directly — besides the promotion part, you can also test new builds of your game on regular people and fix any bugs (or incorporate any feedback) they uncover. You can't imagine what people may come up with when playing your game, and what obvious issues you've missed while spending hours polishing it. ## Promo codes @@ -74,6 +74,6 @@ You can help community grow and promote yourself and your games at the same time ## Summary -Any way of promoting your game is good. You have a lot of options to chose from with most of them being free, so it's only about your enthusiasm and available time. Sometimes you have to spend more time promoting a game than actually developing it. Remember that it's no use to have the best game in the world if no one knows it exists. +Any way of promoting your game is good. You have a lot of options to choose from with most of them being free, so it's only about your enthusiasm and available time. Sometimes you have to spend more time promoting a game than actually developing it. Remember that it's no use to have the best game in the world if no one knows it exists. -Now lets get on with that [monetization](/en-US/docs/Games/Publishing_games/Game_monetization) part, and earn something for a living. +Now, let's get on with that [monetization](/en-US/docs/Games/Publishing_games/Game_monetization) part, and earn something for a living. diff --git a/files/en-us/games/techniques/2d_collision_detection/index.md b/files/en-us/games/techniques/2d_collision_detection/index.md index 929099bf7e4b29f..e733db70b2d3aa3 100644 --- a/files/en-us/games/techniques/2d_collision_detection/index.md +++ b/files/en-us/games/techniques/2d_collision_detection/index.md @@ -131,7 +131,7 @@ circle2.bind("EnterFrame", function () { ## Separating Axis Theorem -This is a collision algorithm that can detect a collision between any two \*convex\* polygons. It's more complicated to implement than the above methods but is more powerful. The complexity of an algorithm like this means we will need to consider performance optimization, covered in the next section. +This is a collision algorithm that can detect a collision between any two _convex_ polygons. It's more complicated to implement than the above methods but is more powerful. The complexity of an algorithm like this means we will need to consider performance optimization, covered in the next section. Implementing SAT is out of scope for this page so see the recommended tutorials below: @@ -143,11 +143,11 @@ Implementing SAT is out of scope for this page so see the recommended tutorials ## Collision Performance -While some of these algorithms for collision detection are simple enough to calculate, it can be a waste of cycles to test \*every\* entity with every other entity. Usually games will split collision into two phases, broad and narrow. +While some of these algorithms for collision detection are simple enough to calculate, it can be a waste of cycles to test _every_ entity with every other entity. Usually games will split collision into two phases, broad and narrow. ### Broad Phase -Broad phase should give you a list of entities that \*could\* be colliding. This can be implemented with a spacial data structure that will give you a rough idea of where the entity exists and what exist around it. Some examples of spacial data structures are Quad Trees, R-Trees or a Spacial Hashmap. +Broad phase should give you a list of entities that _could_ be colliding. This can be implemented with a spacial data structure that will give you a rough idea of where the entity exists and what exist around it. Some examples of spacial data structures are Quad Trees, R-Trees or a Spacial Hashmap. ### Narrow Phase diff --git a/files/en-us/games/techniques/3d_on_the_web/webxr/index.md b/files/en-us/games/techniques/3d_on_the_web/webxr/index.md index 82d27c467fbce29..0090cbc5b64d6c0 100644 --- a/files/en-us/games/techniques/3d_on_the_web/webxr/index.md +++ b/files/en-us/games/techniques/3d_on_the_web/webxr/index.md @@ -18,7 +18,7 @@ With the popularity of existing VR headsets such as Meta Quest, Valve Index, and ### Development of WebVR -The [WebVR spec](https://mozvr.github.io/webvr-spec/webvr.html), led by [Vladimir Vukicevic](https://twitter.com/vvuk) from Mozilla and [Brandon Jones](https://twitter.com/tojiro) from Google, is being replaced by the [WebXR Device API](/en-US/docs/Web/API/WebXR_Device_API). WebVR may still be available in some browsers while WebXR is finalized. +The [WebVR spec](https://mozvr.github.io/webvr-spec/webvr.html) is being replaced by the [WebXR Device API](/en-US/docs/Web/API/WebXR_Device_API). WebVR may still be available in some browsers while WebXR is finalized. For more info, see the [WebVR.info](https://webvr.info/) website. ## The WebXR API diff --git a/files/en-us/games/techniques/audio_for_web_games/index.md b/files/en-us/games/techniques/audio_for_web_games/index.md index ada37a835192fd7..a937448f36f0b27 100644 --- a/files/en-us/games/techniques/audio_for_web_games/index.md +++ b/files/en-us/games/techniques/audio_for_web_games/index.md @@ -226,7 +226,7 @@ Let's look at some Web Audio API techniques for dynamically adjusting music from ### Loading your tracks -With the Web Audio API you can load separate tracks and loops individually using {{domxref("XMLHttpRequest")}} or the [Fetch API](/en-US/docs/Web/API/Fetch_API), which means you can load them synchronously or in parallel. Loading synchronously might mean parts of your music are ready earlier and you can start playing them while others load. +With the Web Audio API you can load separate tracks and loops individually using the [Fetch API](/en-US/docs/Web/API/Fetch_API) or {{domxref("XMLHttpRequest")}}, which means you can load them synchronously or in parallel. Loading synchronously might mean parts of your music are ready earlier and you can start playing them while others load. Either way you may want to synchronize tracks or loops. The Web Audio API contains the notion of an internal clock that starts ticking the moment you create an audio context. You'll need to take account of the time between creating an audio context and when the first audio track starts playing. Recording this offset and querying the playing track's current time gives you enough information to synchronize separate pieces of audio. diff --git a/files/en-us/games/techniques/control_mechanisms/mobile_touch/index.md b/files/en-us/games/techniques/control_mechanisms/mobile_touch/index.md index 5906380ceedc6fd..eddfdeedad10f08 100644 --- a/files/en-us/games/techniques/control_mechanisms/mobile_touch/index.md +++ b/files/en-us/games/techniques/control_mechanisms/mobile_touch/index.md @@ -51,7 +51,7 @@ function touchHandler(e) { if (e.touches) { playerX = e.touches[0].pageX - canvas.offsetLeft - playerWidth / 2; playerY = e.touches[0].pageY - canvas.offsetTop - playerHeight / 2; - output.textContent = `Touch: x: ${playerX}, y: ${playerY}`; + output.textContent = `Touch:\nx: ${playerX}, y: ${playerY}`; e.preventDefault(); } } diff --git a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/bounce_off_the_walls/index.md b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/bounce_off_the_walls/index.md index 1173df8394060f3..86eea7d8a4b15de 100644 --- a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/bounce_off_the_walls/index.md +++ b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/bounce_off_the_walls/index.md @@ -10,7 +10,7 @@ page-type: guide This is the **3rd step** out of 10 of the [Gamedev Canvas tutorial](/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript). You can find the source code as it should look after completing this lesson at [Gamedev-Canvas-workshop/lesson3.html](https://github.com/end3r/Gamedev-Canvas-workshop/blob/gh-pages/lesson03.html). -It is nice to see our ball moving, but it quickly disappears from the screen, limiting the fun we can have with it! To overcome that we will implement some very simple collision detection (which will be explained [later](/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript/Collision_detection) in more detail) to make the ball bounce off the four edges of the Canvas. +It is nice to see our ball moving, but it quickly disappears from the screen, limiting the fun we can have with it! To overcome that we will implement some collision detection (which will be explained [later](/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript/Collision_detection) in more detail) to make the ball bounce off the four edges of the Canvas. ## Simple collision detection @@ -99,7 +99,63 @@ When the distance between the center of the ball and the edge of the wall is exa Let's again check the finished code for this part against what you've got, and have a play: -{{JSFiddleEmbed("https://jsfiddle.net/end3r/redj37dc/","","395")}} +```html hidden + + +``` + +```css hidden +canvas { + background: #eee; +} +button { + display: block; +} +``` + +```js +const canvas = document.getElementById("myCanvas"); +const ctx = canvas.getContext("2d"); +const ballRadius = 10; +let x = canvas.width / 2; +let y = canvas.height - 30; +let dx = 2; +let dy = -2; + +function drawBall() { + ctx.beginPath(); + ctx.arc(x, y, ballRadius, 0, Math.PI * 2); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} + +function draw() { + ctx.clearRect(0, 0, canvas.width, canvas.height); + drawBall(); + + if (x + dx > canvas.width - ballRadius || x + dx < ballRadius) { + dx = -dx; + } + if (y + dy > canvas.height - ballRadius || y + dy < ballRadius) { + dy = -dy; + } + + x += dx; + y += dy; +} + +function startGame() { + const interval = setInterval(draw, 10); +} + +document.getElementById("runButton").addEventListener("click", function () { + startGame(); + this.disabled = true; +}); +``` + +{{embedlivesample("compare_your_code", 600, 360)}} > **Note:** Try changing the color of the ball to a random color every time it hits the wall. diff --git a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/build_the_brick_field/index.md b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/build_the_brick_field/index.md index 0e97fb25dff05e8..b755357c150afd5 100644 --- a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/build_the_brick_field/index.md +++ b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/build_the_brick_field/index.md @@ -103,7 +103,147 @@ drawBricks(); At this point, the game has got a little more interesting again: -{{JSFiddleEmbed("https://jsfiddle.net/raymondjplante/Lu3vtejz/","","395")}} +```html hidden + + +``` + +```css hidden +canvas { + background: #eee; +} +button { + display: block; +} +``` + +```js hidden +const canvas = document.getElementById("myCanvas"); +const ctx = canvas.getContext("2d"); +const ballRadius = 10; + +let x = canvas.width / 2; +let y = canvas.height - 30; + +let dx = 2; +let dy = -2; + +const paddleHeight = 10; +const paddleWidth = 75; + +let paddleX = (canvas.width - paddleWidth) / 2; +let rightPressed = false; +let leftPressed = false; + +const brickRowCount = 3; +const brickColumnCount = 5; +const brickWidth = 75; +const brickHeight = 20; +const brickPadding = 10; +const brickOffsetTop = 30; +const brickOffsetLeft = 30; + +let bricks = []; +for (let c = 0; c < brickColumnCount; c++) { + bricks[c] = []; + for (let r = 0; r < brickRowCount; r++) { + bricks[c][r] = { x: 0, y: 0 }; + } +} + +document.addEventListener("keydown", keyDownHandler, false); +document.addEventListener("keyup", keyUpHandler, false); + +function keyDownHandler(e) { + if (e.key == "Right" || e.key == "ArrowRight") { + rightPressed = true; + } else if (e.key == "Left" || e.key == "ArrowLeft") { + leftPressed = true; + } +} + +function keyUpHandler(e) { + if (e.key == "Right" || e.key == "ArrowRight") { + rightPressed = false; + } else if (e.key == "Left" || e.key == "ArrowLeft") { + leftPressed = false; + } +} + +function drawBall() { + ctx.beginPath(); + ctx.arc(x, y, ballRadius, 0, Math.PI * 2); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} +function drawPaddle() { + ctx.beginPath(); + ctx.rect(paddleX, canvas.height - paddleHeight, paddleWidth, paddleHeight); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} +function drawBricks() { + for (let c = 0; c < brickColumnCount; c++) { + for (let r = 0; r < brickRowCount; r++) { + let brickX = c * (brickWidth + brickPadding) + brickOffsetLeft; + let brickY = r * (brickHeight + brickPadding) + brickOffsetTop; + bricks[c][r].x = brickX; + bricks[c][r].y = brickY; + ctx.beginPath(); + ctx.rect(brickX, brickY, brickWidth, brickHeight); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); + } + } +} + +function draw() { + ctx.clearRect(0, 0, canvas.width, canvas.height); + drawBricks(); + drawBall(); + drawPaddle(); + + if (x + dx > canvas.width - ballRadius || x + dx < ballRadius) { + dx = -dx; + } + if (y + dy < ballRadius) { + dy = -dy; + } else if (y + dy > canvas.height - ballRadius) { + if (x > paddleX && x < paddleX + paddleWidth) { + if ((y = y - paddleHeight)) { + dy = -dy; + } + } else { + alert("GAME OVER"); + document.location.reload(); + clearInterval(interval); // Needed for Chrome to end game + } + } + + if (rightPressed && paddleX < canvas.width - paddleWidth) { + paddleX += 7; + } else if (leftPressed && paddleX > 0) { + paddleX -= 7; + } + + x += dx; + y += dy; +} + +function startGame() { + const interval = setInterval(draw, 10); +} + +document.getElementById("runButton").addEventListener("click", function () { + startGame(); + this.disabled = true; +}); +``` + +{{embedlivesample("compare_your_code", 600, 360)}} > **Note:** Try changing the number of bricks in a row or a column, or their positions. diff --git a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/collision_detection/index.md b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/collision_detection/index.md index 45265bcf101ee6a..130a4cdf26ab10b 100644 --- a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/collision_detection/index.md +++ b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/collision_detection/index.md @@ -58,7 +58,8 @@ Add the above block to your code, below the `keyUpHandler()` function. The above code will work as desired and the ball changes its direction. The problem is that the bricks are staying where they are. We have to figure out a way to get rid of the ones we've already hit with the ball. We can do that by adding an extra parameter to indicate whether we want to paint each brick on the screen or not. In the part of the code where we initialize the bricks, let's add a `status` property to each brick object. Update the following part of the code as indicated by the highlighted line: ```js -const bricks = []; +let bricks = []; + for (let c = 0; c < brickColumnCount; c++) { bricks[c] = []; for (let r = 0; r < brickRowCount; r++) { @@ -124,11 +125,168 @@ collisionDetection(); ## Compare your code -The collision detection of the ball is now checked on every frame, with every brick. Now we can destroy bricks! :- +The collision detection of the ball is now checked on every frame, with every brick. Now we can destroy bricks! :-) + +```html hidden + + +``` + +```css hidden +canvas { + background: #eee; +} +button { + display: block; +} +``` + +```js hidden +const canvas = document.getElementById("myCanvas"); +const ctx = canvas.getContext("2d"); +const ballRadius = 10; + +let x = canvas.width / 2; +let y = canvas.height - 30; +let dx = 2; +let dy = -2; + +const paddleHeight = 10; +const paddleWidth = 75; + +let paddleX = (canvas.width - paddleWidth) / 2; +let rightPressed = false; +let leftPressed = false; + +const brickRowCount = 3; +const brickColumnCount = 5; +const brickWidth = 75; +const brickHeight = 20; +const brickPadding = 10; +const brickOffsetTop = 30; +const brickOffsetLeft = 30; + +let bricks = []; +for (let c = 0; c < brickColumnCount; c++) { + bricks[c] = []; + for (let r = 0; r < brickRowCount; r++) { + bricks[c][r] = { x: 0, y: 0, status: 1 }; + } +} + +document.addEventListener("keydown", keyDownHandler, false); +document.addEventListener("keyup", keyUpHandler, false); + +function keyDownHandler(e) { + if (e.key == "Right" || e.key == "ArrowRight") { + rightPressed = true; + } else if (e.key == "Left" || e.key == "ArrowLeft") { + leftPressed = true; + } +} + +function keyUpHandler(e) { + if (e.key == "Right" || e.key == "ArrowRight") { + rightPressed = false; + } else if (e.key == "Left" || e.key == "ArrowLeft") { + leftPressed = false; + } +} +function collisionDetection() { + for (let c = 0; c < brickColumnCount; c++) { + for (let r = 0; r < brickRowCount; r++) { + let b = bricks[c][r]; + if (b.status == 1) { + if ( + x > b.x && + x < b.x + brickWidth && + y > b.y && + y < b.y + brickHeight + ) { + dy = -dy; + b.status = 0; + } + } + } + } +} +function drawBall() { + ctx.beginPath(); + ctx.arc(x, y, ballRadius, 0, Math.PI * 2); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} +function drawPaddle() { + ctx.beginPath(); + ctx.rect(paddleX, canvas.height - paddleHeight, paddleWidth, paddleHeight); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} +function drawBricks() { + for (let c = 0; c < brickColumnCount; c++) { + for (let r = 0; r < brickRowCount; r++) { + if (bricks[c][r].status == 1) { + let brickX = c * (brickWidth + brickPadding) + brickOffsetLeft; + let brickY = r * (brickHeight + brickPadding) + brickOffsetTop; + bricks[c][r].x = brickX; + bricks[c][r].y = brickY; + ctx.beginPath(); + ctx.rect(brickX, brickY, brickWidth, brickHeight); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); + } + } + } +} + +function draw() { + ctx.clearRect(0, 0, canvas.width, canvas.height); + drawBricks(); + drawBall(); + drawPaddle(); + collisionDetection(); + + if (x + dx > canvas.width - ballRadius || x + dx < ballRadius) { + dx = -dx; + } + if (y + dy < ballRadius) { + dy = -dy; + } else if (y + dy > canvas.height - ballRadius) { + if (x > paddleX && x < paddleX + paddleWidth) { + if ((y = y - paddleHeight)) { + dy = -dy; + } + } else { + alert("GAME OVER"); + document.location.reload(); + clearInterval(interval); // Needed for Chrome to end game + } + } + + if (rightPressed && paddleX < canvas.width - paddleWidth) { + paddleX += 7; + } else if (leftPressed && paddleX > 0) { + paddleX -= 7; + } -{{JSFiddleEmbed("https://jsfiddle.net/yumetodo/kaed3hbu/","","395")}} + x += dx; + y += dy; +} + +function startGame() { + const interval = setInterval(draw, 10); +} + +document.getElementById("runButton").addEventListener("click", function () { + startGame(); + this.disabled = true; +}); +``` -> **Note:** Try changing the color of the ball when it hits the brick. +{{embedlivesample("compare_your_code", 600, 360)}} ## Next steps diff --git a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/create_the_canvas_and_draw_on_it/index.md b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/create_the_canvas_and_draw_on_it/index.md index bffb99ff63ef1a1..0ac2818d772be55 100644 --- a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/create_the_canvas_and_draw_on_it/index.md +++ b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/create_the_canvas_and_draw_on_it/index.md @@ -14,7 +14,7 @@ Before we can start writing the game's functionality, we need to create a basic ## The game's HTML -The HTML document structure is quite simple, as the game will be rendered entirely on the {{htmlelement("canvas")}} element. Using your favorite text editor, create a new HTML document, save it as `index.html`, in a sensible location, and add the following code to it: +The HTML document structure is quite minimal, as the game will be rendered entirely on the {{htmlelement("canvas")}} element. Using your favorite text editor, create a new HTML document, save it as `index.html`, in a sensible location, and add the following code to it: ```html @@ -86,25 +86,58 @@ As you can see we're using the {{domxref("CanvasRenderingContext2D.beginPath()", - start angle and end angle (what angle to start and finish drawing the circle, in radians) - direction of drawing (`false` for clockwise, the default, or `true` for anti-clockwise.) This last parameter is optional. -The {{domxref("CanvasRenderingContext2D.fillStyle","fillStyle")}} property looks different than before. This is because, just as with CSS, color can be specified as a hexadecimal value, a color keyword, the `rgba()` function, or any of the other available color methods. +The {{domxref("CanvasRenderingContext2D.fillStyle","fillStyle")}} property looks different than before. This is because, just as with CSS, color can be specified as a hexadecimal value, a color keyword, the `rgb()` function, or any of the other available color methods. Instead of using {{domxref("CanvasRenderingContext2D.fill()","fill()")}} and filling the shapes with colors, we can use {{domxref("CanvasRenderingContext2D.stroke()","stroke()")}} to only color the outer stroke. Try adding this code to your JavaScript too: ```js ctx.beginPath(); ctx.rect(160, 10, 100, 40); -ctx.strokeStyle = "rgba(0, 0, 255, 0.5)"; +ctx.strokeStyle = "rgb(0 0 255 / 50%)"; ctx.stroke(); ctx.closePath(); ``` -The code above prints a blue-stroked empty rectangle. Thanks to the alpha channel in the `rgba()` function, the blue color is semi transparent. +The code above prints a blue-stroked empty rectangle. Thanks to the alpha channel in the `rgb()` function, the blue color is semi transparent. ## Compare your code -Here's the full source code of the first lesson, running live in a JSFiddle: +Here's the full source code of the first lesson, running live: + +```html + +``` + +```css +canvas { + background: #eee; +} +``` + +```js +const canvas = document.getElementById("myCanvas"); +const ctx = canvas.getContext("2d"); + +ctx.beginPath(); +ctx.rect(20, 40, 50, 50); +ctx.fillStyle = "#FF0000"; +ctx.fill(); +ctx.closePath(); + +ctx.beginPath(); +ctx.arc(240, 160, 20, 0, Math.PI * 2, false); +ctx.fillStyle = "green"; +ctx.fill(); +ctx.closePath(); + +ctx.beginPath(); +ctx.rect(160, 10, 100, 40); +ctx.strokeStyle = "rgba(0, 0, 255, 0.5)"; +ctx.stroke(); +ctx.closePath(); +``` -{{JSFiddleEmbed("https://jsfiddle.net/end3r/x62h15e2/","","395")}} +{{embedlivesample("compare_your_code", 600, 340)}} > **Note:** Try changing the size and color of the given shapes. diff --git a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/finishing_up/index.md b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/finishing_up/index.md index 99fd07e143f0850..fc5b52e09f0db9b 100644 --- a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/finishing_up/index.md +++ b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/finishing_up/index.md @@ -95,15 +95,207 @@ The `draw()` function is now getting executed again and again within a `requestA ## Compare your code -That's all — the final version of the game is ready and set to go ! +That's all — the final version of the game is ready and set to go! -{{JSFiddleEmbed("https://jsfiddle.net/raymondjplante/dfh2tpu1/","","395")}} +```html hidden + + +``` + +```css hidden +canvas { + background: #eee; +} +button { + display: block; +} +``` + +```js hidden +const canvas = document.getElementById("myCanvas"); +const ctx = canvas.getContext("2d"); +const ballRadius = 10; + +let x = canvas.width / 2; +let y = canvas.height - 30; +let dx = 2; +let dy = -2; + +const paddleHeight = 10; +const paddleWidth = 75; + +let paddleX = (canvas.width - paddleWidth) / 2; +let rightPressed = false; +let leftPressed = false; + +const brickRowCount = 5; +const brickColumnCount = 3; +const brickWidth = 75; +const brickHeight = 20; +const brickPadding = 10; +const brickOffsetTop = 30; +const brickOffsetLeft = 30; + +let score = 0; +let lives = 3; + +let bricks = []; + +for (let c = 0; c < brickColumnCount; c++) { + bricks[c] = []; + for (let r = 0; r < brickRowCount; r++) { + bricks[c][r] = { x: 0, y: 0, status: 1 }; + } +} + +document.addEventListener("keydown", keyDownHandler, false); +document.addEventListener("keyup", keyUpHandler, false); +document.addEventListener("mousemove", mouseMoveHandler, false); + +function keyDownHandler(e) { + if (e.key == "Right" || e.key == "ArrowRight") { + rightPressed = true; + } else if (e.key == "Left" || e.key == "ArrowLeft") { + leftPressed = true; + } +} + +function keyUpHandler(e) { + if (e.key == "Right" || e.key == "ArrowRight") { + rightPressed = false; + } else if (e.key == "Left" || e.key == "ArrowLeft") { + leftPressed = false; + } +} + +function mouseMoveHandler(e) { + let relativeX = e.clientX - canvas.offsetLeft; + if (relativeX > 0 && relativeX < canvas.width) { + paddleX = relativeX - paddleWidth / 2; + } +} +function collisionDetection() { + for (let c = 0; c < brickColumnCount; c++) { + for (let r = 0; r < brickRowCount; r++) { + let b = bricks[c][r]; + if (b.status == 1) { + if ( + x > b.x && + x < b.x + brickWidth && + y > b.y && + y < b.y + brickHeight + ) { + dy = -dy; + b.status = 0; + score++; + if (score == brickRowCount * brickColumnCount) { + alert("YOU WIN, CONGRATS!"); + document.location.reload(); + } + } + } + } + } +} + +function drawBall() { + ctx.beginPath(); + ctx.arc(x, y, ballRadius, 0, Math.PI * 2); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} +function drawPaddle() { + ctx.beginPath(); + ctx.rect(paddleX, canvas.height - paddleHeight, paddleWidth, paddleHeight); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} +function drawBricks() { + for (let c = 0; c < brickColumnCount; c++) { + for (let r = 0; r < brickRowCount; r++) { + if (bricks[c][r].status == 1) { + const brickX = r * (brickWidth + brickPadding) + brickOffsetLeft; + const brickY = c * (brickHeight + brickPadding) + brickOffsetTop; + bricks[c][r].x = brickX; + bricks[c][r].y = brickY; + ctx.beginPath(); + ctx.rect(brickX, brickY, brickWidth, brickHeight); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); + } + } + } +} +function drawScore() { + ctx.font = "16px Arial"; + ctx.fillStyle = "#0095DD"; + ctx.fillText("Score: " + score, 8, 20); +} +function drawLives() { + ctx.font = "16px Arial"; + ctx.fillStyle = "#0095DD"; + ctx.fillText("Lives: " + lives, canvas.width - 65, 20); +} + +function draw() { + ctx.clearRect(0, 0, canvas.width, canvas.height); + drawBricks(); + drawBall(); + drawPaddle(); + drawScore(); + drawLives(); + collisionDetection(); + + if (x + dx > canvas.width - ballRadius || x + dx < ballRadius) { + dx = -dx; + } + if (y + dy < ballRadius) { + dy = -dy; + } else if (y + dy > canvas.height - ballRadius) { + if (x > paddleX && x < paddleX + paddleWidth) { + dy = -dy; + } else { + lives--; + if (!lives) { + alert("GAME OVER"); + document.location.reload(); + } else { + x = canvas.width / 2; + y = canvas.height - 30; + dx = 3; + dy = -3; + paddleX = (canvas.width - paddleWidth) / 2; + } + } + } + + if (rightPressed && paddleX < canvas.width - paddleWidth) { + paddleX += 7; + } else if (leftPressed && paddleX > 0) { + paddleX -= 7; + } + + x += dx; + y += dy; + requestAnimationFrame(draw); +} + +document.getElementById("runButton").addEventListener("click", function () { + draw(); + this.disabled = true; +}); +``` + +{{embedlivesample("compare_your_code", 600, 360)}} > **Note:**: Try changing the number of lives and the angle the ball bounces off the paddle. ## Game over - for now! -You've finished all the lessons - congratulations! By this point, you should now know the basics of canvas manipulation and the logic behind simple 2D games. Now it's a good time to learn some frameworks and continue game development. You can check out this series' counterpart, [2D breakout game using Phaser](/en-US/docs/Games/Tutorials/2D_breakout_game_Phaser) or the [Cyber Orb built in Phaser](/en-US/docs/Games/Tutorials/HTML5_Gamedev_Phaser_Device_Orientation) tutorial. You can also look through the [Games section on MDN](/en-US/docs/Games) for inspiration and more knowledge. +You've finished all the lessons - congratulations! By this point, you should now know the basics of canvas manipulation and the logic behind 2D games. Now it's a good time to learn some frameworks and continue game development. You can check out this series' counterpart, [2D breakout game using Phaser](/en-US/docs/Games/Tutorials/2D_breakout_game_Phaser) or the [Cyber Orb built in Phaser](/en-US/docs/Games/Tutorials/HTML5_Gamedev_Phaser_Device_Orientation) tutorial. You can also look through the [Games section on MDN](/en-US/docs/Games) for inspiration and more knowledge. You could also go back to [this tutorial series' index page](/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript). Have fun coding! diff --git a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/game_over/index.md b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/game_over/index.md index 4909dc144714bde..027cec5f375af61 100644 --- a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/game_over/index.md +++ b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/game_over/index.md @@ -10,7 +10,7 @@ page-type: guide This is the **5th step** out of 10 of the [Gamedev Canvas tutorial](/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript). You can find the source code as it should look after completing this lesson at [Gamedev-Canvas-workshop/lesson5.html](https://github.com/end3r/Gamedev-Canvas-workshop/blob/gh-pages/lesson05.html). -It's fun to watch the ball bouncing off the walls and be able to move the paddle around, but other than that the game does nothing and doesn't have any progression or end goal. It would be good from the gameplay point of view to be able to lose. The logic behind losing in breakout is simple. If you miss the ball with the paddle and let it reach the bottom edge of the screen, then it's game over. +It's fun to watch the ball bouncing off the walls and be able to move the paddle around, but other than that the game does nothing and doesn't have any progression or end goal. It would be good from the gameplay point of view to be able to lose. The logic behind losing in breakout is that if you miss the ball with the paddle and let it reach the bottom edge of the screen, then it's game over. ## Implementing game over @@ -26,7 +26,7 @@ if (y + dy > canvas.height - ballRadius || y + dy < ballRadius) { } ``` -Instead of allowing the ball to bounce off all four walls, let's only allow three now — left, top and right. Hitting the bottom wall will end the game. We'll edit the second if block so it's an if else block that will trigger our "game over" state upon the ball colliding with the bottom edge of the canvas. For now we'll keep it simple, showing an alert message and restarting the game by reloading the page. +Instead of allowing the ball to bounce off all four walls, let's only allow three now — left, top and right. Hitting the bottom wall will end the game. We'll edit the second if block so it's an if else block that will trigger our "game over" state upon the ball colliding with the bottom edge of the canvas. For now we'll show an alert message and restarting the game by reloading the page. First, replace where you initially called `setInterval()` @@ -74,9 +74,114 @@ If the ball hits the bottom edge of the Canvas we need to check whether it hits ## Compare your code -Here's the working code for you to compare yours against: +See how your code compares to the live sample below: -{{JSFiddleEmbed("https://jsfiddle.net/raymondjplante/L61c9y50/","","395")}} +```html hidden + + +``` + +```css hidden +canvas { + background: #eee; +} +button { + display: block; +} +``` + +```js hidden +const canvas = document.getElementById("myCanvas"); +const ctx = canvas.getContext("2d"); +const ballRadius = 10; + +let x = canvas.width / 2; +let y = canvas.height - 30; +let dx = 2; +let dy = -2; + +const paddleHeight = 10; +const paddleWidth = 75; + +let paddleX = (canvas.width - paddleWidth) / 2; +let rightPressed = false; +let leftPressed = false; + +document.addEventListener("keydown", keyDownHandler, false); +document.addEventListener("keyup", keyUpHandler, false); + +function keyDownHandler(e) { + if (e.key == "Right" || e.key == "ArrowRight") { + rightPressed = true; + } else if (e.key == "Left" || e.key == "ArrowLeft") { + leftPressed = true; + } +} + +function keyUpHandler(e) { + if (e.key == "Right" || e.key == "ArrowRight") { + rightPressed = false; + } else if (e.key == "Left" || e.key == "ArrowLeft") { + leftPressed = false; + } +} + +function drawBall() { + ctx.beginPath(); + ctx.arc(x, y, ballRadius, 0, Math.PI * 2); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} +function drawPaddle() { + ctx.beginPath(); + ctx.rect(paddleX, canvas.height - paddleHeight, paddleWidth, paddleHeight); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} + +function draw() { + ctx.clearRect(0, 0, canvas.width, canvas.height); + drawBall(); + drawPaddle(); + + if (x + dx > canvas.width - ballRadius || x + dx < ballRadius) { + dx = -dx; + } + if (y + dy < ballRadius) { + dy = -dy; + } else if (y + dy > canvas.height - ballRadius) { + if (x > paddleX && x < paddleX + paddleWidth) { + dy = -dy; + } else { + alert("GAME OVER"); + document.location.reload(); + clearInterval(interval); // Needed for Chrome to end game + } + } + + if (rightPressed && paddleX < canvas.width - paddleWidth) { + paddleX += 7; + } else if (leftPressed && paddleX > 0) { + paddleX -= 7; + } + + x += dx; + y += dy; +} + +function startGame() { + let interval = setInterval(draw, 10); +} + +document.getElementById("runButton").addEventListener("click", function () { + startGame(); + this.disabled = true; +}); +``` + +{{embedlivesample("compare_your_code", 600, 360)}} > **Note:** Try making the ball move faster when it hits the paddle. diff --git a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/index.md b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/index.md index 61adc1d779a7411..015b4bd1a23d1f6 100644 --- a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/index.md +++ b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/index.md @@ -8,11 +8,11 @@ page-type: guide {{Next("Games/Workflows/2D_Breakout_game_pure_JavaScript/Create_the_Canvas_and_draw_on_it")}} -In this step-by-step tutorial we create a simple **MDN Breakout** game written entirely in pure JavaScript and rendered on HTML {{htmlelement("canvas")}}. +In this step-by-step tutorial we create an **MDN Breakout** game written entirely in pure JavaScript and rendered on HTML {{htmlelement("canvas")}}. Every step has editable, live samples available to play with so you can see what the intermediate stages should look like. You will learn the basics of using the {{htmlelement("canvas")}} element to implement fundamental game mechanics like rendering and moving images, collision detection, control mechanisms, and winning and losing states. -To get the most out of this series of articles you should already have basic to intermediate [JavaScript](/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics) knowledge. After working through this tutorial you should be able to build your own simple Web games. +To get the most out of this series of articles you should already have basic to intermediate [JavaScript](/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics) knowledge. After working through this tutorial you should be able to build your own Web games. ![Gameplay screen from the game MDN Breakout where you can use your paddle to bounce the ball and destroy the brick field, with keeping the score and lives.](mdn-breakout-gameplay.png) @@ -33,12 +33,13 @@ All the lessons — and the different versions of the [MDN Breakout game](https: Starting with pure JavaScript is the best way to get a solid knowledge of web game development. After that, you can pick any framework you like and use it for your projects. Frameworks are just tools built with the JavaScript language; so even if you plan on working with them, it's good to learn about the language itself first to know what exactly is going on under the hood. Frameworks speed up development time and help take care of boring parts of the game, but if something is not working as expected, you can always try to debug that or just write your own solutions in pure JavaScript. -> **Note:** If you are interested in learning about 2D web game development using a game library, consult this series' counterpart, [2D breakout game using Phaser](/en-US/docs/Games/Tutorials/2D_breakout_game_Phaser). - -> **Note:** This series of articles can be used as material for hands-on game development workshops. You can also make use of the [Gamedev Canvas Content Kit](https://github.com/end3r/Gamedev-Canvas-Content-Kit) based on this tutorial if you want to give a talk about game development in general. +> **Note:** +> This series of articles can be used as material for hands-on game development workshops. You can also make use of the [Gamedev Canvas Content Kit](https://github.com/end3r/Gamedev-Canvas-Content-Kit) based on this tutorial if you want to give a talk about game development in general. +> +> If you are interested in using a game library for learning about 2D web game development, see this series' counterpart, [2D breakout game using Phaser](/en-US/docs/Games/Tutorials/2D_breakout_game_Phaser). ## Next steps -Ok, let's get started! Head to the first chapter— [Create the Canvas and draw on it](/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript/Create_the_Canvas_and_draw_on_it). +Ok, let's get started! Head to the first chapter [Create the Canvas and draw on it](/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript/Create_the_Canvas_and_draw_on_it). {{Next("Games/Workflows/2D_Breakout_game_pure_JavaScript/Create_the_Canvas_and_draw_on_it")}} diff --git a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/mouse_controls/index.md b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/mouse_controls/index.md index 5e53060bc06b5cd..6cbddde3bdb6987 100644 --- a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/mouse_controls/index.md +++ b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/mouse_controls/index.md @@ -41,7 +41,186 @@ The paddle will now follow the position of the mouse cursor, but since we're res This is the latest state of the code to compare against: -{{JSFiddleEmbed("https://jsfiddle.net/raymondjplante/vt7y5hcp/","","395")}} +```html hidden + + +``` + +```css hidden +canvas { + background: #eee; +} +button { + display: block; +} +``` + +```js hidden +const canvas = document.getElementById("myCanvas"); +const ctx = canvas.getContext("2d"); +const ballRadius = 10; + +let x = canvas.width / 2; +let y = canvas.height - 30; +let dx = 2; +let dy = -2; + +const paddleHeight = 10; +const paddleWidth = 75; + +let paddleX = (canvas.width - paddleWidth) / 2; +let rightPressed = false; +let leftPressed = false; + +const brickRowCount = 5; +const brickColumnCount = 3; +const brickWidth = 75; +const brickHeight = 20; +const brickPadding = 10; +const brickOffsetTop = 30; +const brickOffsetLeft = 30; + +let score = 0; +let bricks = []; + +for (let c = 0; c < brickColumnCount; c++) { + bricks[c] = []; + for (let r = 0; r < brickRowCount; r++) { + bricks[c][r] = { x: 0, y: 0, status: 1 }; + } +} + +document.addEventListener("keydown", keyDownHandler, false); +document.addEventListener("keyup", keyUpHandler, false); +document.addEventListener("mousemove", mouseMoveHandler, false); + +function keyDownHandler(e) { + if (e.key == "Right" || e.key == "ArrowRight") { + rightPressed = true; + } else if (e.key == "Left" || e.key == "ArrowLeft") { + leftPressed = true; + } +} + +function keyUpHandler(e) { + if (e.key == "Right" || e.key == "ArrowRight") { + rightPressed = false; + } else if (e.key == "Left" || e.key == "ArrowLeft") { + leftPressed = false; + } +} + +function mouseMoveHandler(e) { + const relativeX = e.clientX - canvas.offsetLeft; + if (relativeX > 0 && relativeX < canvas.width) { + paddleX = relativeX - paddleWidth / 2; + } +} +function collisionDetection() { + for (let c = 0; c < brickColumnCount; c++) { + for (let r = 0; r < brickRowCount; r++) { + let b = bricks[c][r]; + if (b.status == 1) { + if ( + x > b.x && + x < b.x + brickWidth && + y > b.y && + y < b.y + brickHeight + ) { + dy = -dy; + b.status = 0; + score++; + if (score == brickRowCount * brickColumnCount) { + alert("YOU WIN, CONGRATS!"); + document.location.reload(); + clearInterval(interval); // Needed for Chrome to end game + } + } + } + } + } +} + +function drawBall() { + ctx.beginPath(); + ctx.arc(x, y, ballRadius, 0, Math.PI * 2); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} +function drawPaddle() { + ctx.beginPath(); + ctx.rect(paddleX, canvas.height - paddleHeight, paddleWidth, paddleHeight); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} +function drawBricks() { + for (let c = 0; c < brickColumnCount; c++) { + for (let r = 0; r < brickRowCount; r++) { + if (bricks[c][r].status == 1) { + const brickX = r * (brickWidth + brickPadding) + brickOffsetLeft; + const brickY = c * (brickHeight + brickPadding) + brickOffsetTop; + bricks[c][r].x = brickX; + bricks[c][r].y = brickY; + ctx.beginPath(); + ctx.rect(brickX, brickY, brickWidth, brickHeight); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); + } + } + } +} +function drawScore() { + ctx.font = "16px Arial"; + ctx.fillStyle = "#0095DD"; + ctx.fillText("Score: " + score, 8, 20); +} + +function draw() { + ctx.clearRect(0, 0, canvas.width, canvas.height); + drawBricks(); + drawBall(); + drawPaddle(); + drawScore(); + collisionDetection(); + + if (x + dx > canvas.width - ballRadius || x + dx < ballRadius) { + dx = -dx; + } + if (y + dy < ballRadius) { + dy = -dy; + } else if (y + dy > canvas.height - ballRadius) { + if (x > paddleX && x < paddleX + paddleWidth) { + dy = -dy; + } else { + alert("GAME OVER"); + document.location.reload(); + clearInterval(interval); // Needed for Chrome to end game + } + } + + if (rightPressed && paddleX < canvas.width - paddleWidth) { + paddleX += 7; + } else if (leftPressed && paddleX > 0) { + paddleX -= 7; + } + + x += dx; + y += dy; +} + +function startGame() { + const interval = setInterval(draw, 10); +} + +document.getElementById("runButton").addEventListener("click", function () { + startGame(); +}); +``` + +{{embedlivesample("compare_your_code", 600, 360)}} > **Note:** Try adjusting the boundaries of the paddle movement, so the whole paddle will be visible on both edges of the Canvas instead of only half of it. diff --git a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/move_the_ball/index.md b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/move_the_ball/index.md index 845f0033fb906b4..9b1d492dc57a9d7 100644 --- a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/move_the_ball/index.md +++ b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/move_the_ball/index.md @@ -14,7 +14,8 @@ You already know how to draw a ball from working through the previous article, s ## Defining a drawing loop -To keep constantly updating the canvas drawing on each frame, we need to define a drawing function that will run over and over again, with a different set of variable values each time to change sprite positions, etc. You can run a function over and over again using a JavaScript timing function such as {{domxref("setInterval()")}} or {{domxref("window.requestAnimationFrame()", "requestAnimationFrame()")}}. +To keep constantly updating the canvas drawing on each frame, we need to define a drawing function that will run over and over again, with a different set of variable values each time to change sprite positions, etc. You can run a function over and over again using a JavaScript timing function. +Later on in the tutorial, we'll see how {{domxref("window.requestAnimationFrame()", "requestAnimationFrame()")}} helps with drawing, but we'll start with {{domxref("setInterval()")}} at first to create some looping logic. Delete all the JavaScript you currently have inside your HTML file except for the first two lines, and add the following below them. The `draw()` function will be executed within `setInterval` every 10 milliseconds: @@ -108,7 +109,7 @@ Save your code and try again, and this time you'll see the ball move without a t ## Cleaning up our code -We will be adding more and more commands to the `draw()` function in the next few articles, so it's good to keep it as simple and clean as possible. Let's start by moving the ball drawing code to a separate function. +We will be adding more and more commands to the `draw()` function in the next few articles, so it's good to keep it as minimal and clean as possible. Let's start by moving the ball drawing code to a separate function. Replace the existing draw() function with the following two functions: @@ -131,9 +132,59 @@ function draw() { ## Compare your code -You can check the finished code for this article for yourself in the live demo below, and play with it to understand better how it works: +You can check the finished code for this article in the live demo below and play with it to understand better how it works. -{{JSFiddleEmbed("https://jsfiddle.net/end3r/3x5foxb1/","","395")}} +> **Note:** Live samples run automatically on these pages, so we've added a "start game" button. +> This is useful to avoid games starting automatically and triggering alerts or other events too often. + +```html + + +``` + +```css +canvas { + background: #eee; +} +button { + display: block; +} +``` + +```js +const canvas = document.getElementById("myCanvas"); +const ctx = canvas.getContext("2d"); +let x = canvas.width / 2; +let y = canvas.height - 30; +const dx = 2; +const dy = -2; + +function drawBall() { + ctx.beginPath(); + ctx.arc(x, y, 10, 0, Math.PI * 2); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} + +function draw() { + ctx.clearRect(0, 0, canvas.width, canvas.height); + drawBall(); + x += dx; + y += dy; +} + +function startGame() { + const interval = setInterval(draw, 10); +} + +document.getElementById("runButton").addEventListener("click", function () { + startGame(); + this.disabled = true; +}); +``` + +{{embedlivesample("compare_your_code", 600, 350)}} > **Note:** Try changing the speed of the moving ball, or the direction it moves in. diff --git a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/paddle_and_keyboard_controls/index.md b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/paddle_and_keyboard_controls/index.md index 1d0b3d971430862..bc0c7f42c4c5be6 100644 --- a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/paddle_and_keyboard_controls/index.md +++ b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/paddle_and_keyboard_controls/index.md @@ -115,14 +115,114 @@ drawPaddle(); ## Compare your code -Here's the working code for you to compare yours against: +See how your code compares to the live sample below: -{{JSFiddleEmbed("https://jsfiddle.net/L9xfn4up/1/","","395")}} +```html hidden + + +``` + +```css hidden +canvas { + background: #eee; +} +button { + display: block; +} +``` + +```js hidden +const canvas = document.getElementById("myCanvas"); +const ctx = canvas.getContext("2d"); +const ballRadius = 10; +let x = canvas.width / 2; +let y = canvas.height - 30; +let dx = 2; +let dy = -2; +const paddleHeight = 10; +const paddleWidth = 75; +let paddleX = (canvas.width - paddleWidth) / 2; +let rightPressed = false; +let leftPressed = false; + +document.addEventListener("keydown", keyDownHandler, false); +document.addEventListener("keyup", keyUpHandler, false); + +function keyDownHandler(e) { + if (e.key == "Right" || e.key == "ArrowRight") { + rightPressed = true; + } else if (e.key == "Left" || e.key == "ArrowLeft") { + leftPressed = true; + } +} + +function keyUpHandler(e) { + if (e.key == "Right" || e.key == "ArrowRight") { + rightPressed = false; + } else if (e.key == "Left" || e.key == "ArrowLeft") { + leftPressed = false; + } +} + +function drawBall() { + ctx.beginPath(); + ctx.arc(x, y, ballRadius, 0, Math.PI * 2); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} +function drawPaddle() { + ctx.beginPath(); + ctx.rect(paddleX, canvas.height - paddleHeight, paddleWidth, paddleHeight); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} + +function draw() { + ctx.clearRect(0, 0, canvas.width, canvas.height); + drawBall(); + drawPaddle(); + + if (x + dx > canvas.width - ballRadius || x + dx < ballRadius) { + dx = -dx; + } + if (y + dy > canvas.height - ballRadius || y + dy < ballRadius) { + dy = -dy; + } + + if (rightPressed) { + paddleX += 7; + if (paddleX + paddleWidth > canvas.width) { + paddleX = canvas.width - paddleWidth; + } + } else if (leftPressed) { + paddleX -= 7; + if (paddleX < 0) { + paddleX = 0; + } + } + + x += dx; + y += dy; +} + +function startGame() { + const interval = setInterval(draw, 10); +} + +document.getElementById("runButton").addEventListener("click", function () { + startGame(); + this.disabled = true; +}); +``` + +{{embedlivesample("compare_your_code", 600, 360)}} > **Note:** Try making the paddle move faster or slower, or change its size. ## Next steps -Now we have something resembling a game. The only trouble now is that you can just continue hitting the ball with the paddle forever. This will all change in the fifth chapter, [Game over](/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript/Game_over), when we start to add in an endgame state for our game. +Now we have something resembling a game. The only trouble now is that you can just continue hitting the ball with the paddle and there's no winning or losing implemented. This will all change in the fifth chapter, [Game over](/en-US/docs/Games/Tutorials/2D_Breakout_game_pure_JavaScript/Game_over), when we start to add in an endgame state for our game. {{PreviousNext("Games/Workflows/2D_Breakout_game_pure_JavaScript/Bounce_off_the_walls", "Games/Workflows/2D_Breakout_game_pure_JavaScript/Game_over")}} diff --git a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/track_the_score_and_win/index.md b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/track_the_score_and_win/index.md index 799e526085ad22f..74434d6a8c68cf8 100644 --- a/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/track_the_score_and_win/index.md +++ b/files/en-us/games/tutorials/2d_breakout_game_pure_javascript/track_the_score_and_win/index.md @@ -99,7 +99,173 @@ Thanks to this, your users can actually win the game when they destroy all the b The latest code looks (and works) like this, in case you want to compare and contrast it with yours: -{{JSFiddleEmbed("https://jsfiddle.net/raymondjplante/b3z2Lpu9/","","395")}} +```html hidden + + +``` + +```css hidden +canvas { + background: #eee; +} +button { + display: block; +} +``` + +```js hidden +const canvas = document.getElementById("myCanvas"); +const ctx = canvas.getContext("2d"); +const ballRadius = 10; +let x = canvas.width / 2; +let y = canvas.height - 30; +let dx = 2; +let dy = -2; +const paddleHeight = 10; +const paddleWidth = 75; +let paddleX = (canvas.width - paddleWidth) / 2; +let rightPressed = false; +let leftPressed = false; +const brickRowCount = 5; +const brickColumnCount = 3; +const brickWidth = 75; +const brickHeight = 20; +const brickPadding = 10; +const brickOffsetTop = 30; +const brickOffsetLeft = 30; +let score = 0; + +let bricks = []; +for (let c = 0; c < brickColumnCount; c++) { + bricks[c] = []; + for (let r = 0; r < brickRowCount; r++) { + bricks[c][r] = { x: 0, y: 0, status: 1 }; + } +} + +document.addEventListener("keydown", keyDownHandler, false); +document.addEventListener("keyup", keyUpHandler, false); + +function keyDownHandler(e) { + if (e.key == "Right" || e.key == "ArrowRight") { + rightPressed = true; + } else if (e.key == "Left" || e.key == "ArrowLeft") { + leftPressed = true; + } +} + +function keyUpHandler(e) { + if (e.key == "Right" || e.key == "ArrowRight") { + rightPressed = false; + } else if (e.key == "Left" || e.key == "ArrowLeft") { + leftPressed = false; + } +} +function collisionDetection() { + for (let c = 0; c < brickColumnCount; c++) { + for (let r = 0; r < brickRowCount; r++) { + let b = bricks[c][r]; + if (b.status == 1) { + if ( + x > b.x && + x < b.x + brickWidth && + y > b.y && + y < b.y + brickHeight + ) { + dy = -dy; + b.status = 0; + score++; + if (score == brickRowCount * brickColumnCount) { + alert("YOU WIN, CONGRATS!"); + document.location.reload(); + clearInterval(interval); // Needed for Chrome to end game + } + } + } + } + } +} + +function drawBall() { + ctx.beginPath(); + ctx.arc(x, y, ballRadius, 0, Math.PI * 2); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} +function drawPaddle() { + ctx.beginPath(); + ctx.rect(paddleX, canvas.height - paddleHeight, paddleWidth, paddleHeight); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); +} +function drawBricks() { + for (let c = 0; c < brickColumnCount; c++) { + for (let r = 0; r < brickRowCount; r++) { + if (bricks[c][r].status == 1) { + const brickX = r * (brickWidth + brickPadding) + brickOffsetLeft; + const brickY = c * (brickHeight + brickPadding) + brickOffsetTop; + bricks[c][r].x = brickX; + bricks[c][r].y = brickY; + ctx.beginPath(); + ctx.rect(brickX, brickY, brickWidth, brickHeight); + ctx.fillStyle = "#0095DD"; + ctx.fill(); + ctx.closePath(); + } + } + } +} +function drawScore() { + ctx.font = "16px Arial"; + ctx.fillStyle = "#0095DD"; + ctx.fillText("Score: " + score, 8, 20); +} + +function draw() { + ctx.clearRect(0, 0, canvas.width, canvas.height); + drawBricks(); + drawBall(); + drawPaddle(); + drawScore(); + collisionDetection(); + + if (x + dx > canvas.width - ballRadius || x + dx < ballRadius) { + dx = -dx; + } + if (y + dy < ballRadius) { + dy = -dy; + } else if (y + dy > canvas.height - ballRadius) { + if (x > paddleX && x < paddleX + paddleWidth) { + dy = -dy; + } else { + alert("GAME OVER"); + document.location.reload(); + clearInterval(interval); // Needed for Chrome to end game + } + } + + if (rightPressed && paddleX < canvas.width - paddleWidth) { + paddleX += 7; + } else if (leftPressed && paddleX > 0) { + paddleX -= 7; + } + + x += dx; + y += dy; +} + +function startGame() { + const interval = setInterval(draw, 10); +} + +document.getElementById("runButton").addEventListener("click", function () { + startGame(); +}); +``` + +{{embedlivesample("compare_your_code", 600, 360)}} > **Note:** Try adding more points per brick hit, print out the number of collected points in the end game alert box. diff --git a/files/en-us/glossary/accessible_description/index.md b/files/en-us/glossary/accessible_description/index.md new file mode 100644 index 000000000000000..c42ef0e3bf6e701 --- /dev/null +++ b/files/en-us/glossary/accessible_description/index.md @@ -0,0 +1,27 @@ +--- +title: Accessible description +slug: Glossary/Accessible_description +page-type: glossary-definition +--- + +{{GlossarySidebar}} + +An **accessible description** is the description of a user interface element that provides additional information to help users of assistive technology understand the UI element and its context. It is a text description associated with an HTML element that provides users of assistive technology with a description for the element beyond what is provided by the element's {{glossary("accessible name")}}. + +An element's accessible description is part of the {{glossary("accessibility tree")}} that makes web content available to {{glossary("Screen_reader", "screen readers")}} and other assistive technologies, which, in turn, make that content available to the users of those technologies. + +The accessible description for a {{htmlelement("table")}} is its first {{htmlelement("caption")}}, for the {{htmlelement("figure")}}, is the {{htmlelement("figcaption")}}, for the {{htmlelement("summary")}}, is the content of the {{htmlelement("details")}} it is nested in, and for the button {{htmlelement("input")}} elements, it is the `value` attribute's value, unless the element also has a `aria-describedby` or `aria-description` attribute, which takes precedence. + +For other elements, the description needs to be programmatically associated with the related element. In these cases, the accessible description is provided by the [`aria-describedby`](/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) attribute, [`aria-description`](/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-description) attribute, or the [`title`](/en-US/docs/Web/HTML/Global_attributes#title) attribute, if the `title` would not otherwise also be the {{glossary("accessible name")}} for that element, in that order of precedence. + +Descriptions are reduced to text strings. For example, if an element's `aria-describedby` attribute value is the `id` of an HTML {{htmlelement("img")}}, the description is the description of the image (usually the image's `alt` attribute). + +You can inspect the accessible description for any element on your page: look at your browser's developer tools' accessibility tab, which provides the accessibility information for the currently selected element. + +## See also + +- {{glossary("accessible name")}} glossary term +- [ARIA roles](/en-US/docs/Web/Accessibility/ARIA/Roles) +- [ARIA attribute](/en-US/docs/Web/Accessibility/ARIA/Attributes) +- [Accessibility](/en-US/docs/Web/Accessibility) +- [Learn accessibility](/en-US/docs/Learn/Accessibility) diff --git a/files/en-us/glossary/alpha/index.md b/files/en-us/glossary/alpha/index.md index 82e5c2874f91add..a977201ce7405ff 100644 --- a/files/en-us/glossary/alpha/index.md +++ b/files/en-us/glossary/alpha/index.md @@ -8,7 +8,7 @@ page-type: glossary-definition The **alpha channel** specifies to opacity of a ({{CSSxRef("<color>")}}). Colors are represented in digital form as a collection of numbers, each representing the strength or intensity level of a given component of the color. Each of these components is called a **channel**. In a typical image file, the color channels describe how much red, green, and blue are used to make up the final color. To represent a color through which the background can be seen to some extent, a fourth channel is added to the color: the alpha channel. -For example, the color `#8921F2` (also described as `rgb(137 33 242)` or `hsl(270 89% 54)`) is a nice shade of purple. Below you see a small box of that color in the top-left corner and a box of the _same_ color but with an alpha channel set at 0.5 (50% opacity), `#8921F280`, where `80` is the hexadecimal equivalent of 50%. This color is also described as `rgb(137 33 242 / 0.5)` or `hsl(270 89% 54 / 0.5)`. The two boxes are drawn on top of a paragraph of text. +For example, the color `#8921F2` (also described as `rgb(137 33 242)` or `hsl(270 89% 54)`) is a nice shade of purple. Below you see a small box of that color in the top-left corner and a box of the _same_ color but with an alpha channel set at 50% (or 0.5) opacity, `#8921F280`, where `80` is the hexadecimal equivalent of 50%. This color is also described as `rgb(137 33 242 / 50%)` or `hsl(270 89% 54 / 50%)`. The two boxes are drawn on top of a paragraph of text. ![Image showing the effect of an alpha channel on a color.](alpha-channel-example.png) diff --git a/files/en-us/glossary/block-level_content/index.md b/files/en-us/glossary/block-level_content/index.md index 40f124af7e9b4c4..e8ee50a3a8833dc 100644 --- a/files/en-us/glossary/block-level_content/index.md +++ b/files/en-us/glossary/block-level_content/index.md @@ -42,6 +42,6 @@ p { ## See also - [Inline-level content](/en-US/docs/Glossary/Inline-level_content) -- [Block formatting context](/en-US/docs/Web/Guide/CSS/Block_formatting_context) +- [Block formatting context](/en-US/docs/Web/CSS/CSS_display/Block_formatting_context) - {{cssxref("display")}} - [`writing-mode`](/en-US/docs/Web/CSS/writing-mode) diff --git a/files/en-us/glossary/cacheable/index.md b/files/en-us/glossary/cacheable/index.md index 898c037bb44fe9a..864dffa952c213d 100644 --- a/files/en-us/glossary/cacheable/index.md +++ b/files/en-us/glossary/cacheable/index.md @@ -6,15 +6,15 @@ page-type: glossary-definition {{GlossarySidebar}} -A **cacheable** response is an HTTP response that can be cached, that is stored to be retrieved and used later, saving a new request to the server. Not all HTTP responses can be cached, these are the following constraints for an HTTP response to be cached: +A **cacheable** response is an HTTP response that can be cached, that is stored to be retrieved and used later, saving a new request to the server. Not all HTTP responses can be cached; these are the constraints for an HTTP response to be cacheable: -- The method used in the request is itself _cacheable_, that is either a {{HTTPMethod("GET")}} or a {{HTTPMethod("HEAD")}} method. A response to a {{HTTPMethod("POST")}} or {{HTTPMethod("PATCH")}} request can also be cached if freshness is indicated and the {{HTTPHeader("Content-Location")}} header is set, but this is rarely implemented. For example, Firefox does not support it ([Firefox bug 109553](https://bugzil.la/109553)). Other methods, like {{HTTPMethod("PUT")}} or {{HTTPMethod("DELETE")}} are not cacheable and their result cannot be cached. -- The status code of the response is _known_ by the application caching, and it is considered _cacheable_. The following status code are cacheable: {{HTTPStatus("200")}}, {{HTTPStatus("203")}}, {{HTTPStatus("204")}}, {{HTTPStatus("206")}}, {{HTTPStatus("300")}}, {{HTTPStatus("301")}}, {{HTTPStatus("404")}}, {{HTTPStatus("405")}}, {{HTTPStatus("410")}}, {{HTTPStatus("414")}}, and {{HTTPStatus("501")}}. -- There are _specific headers_ in the response, like {{HTTPHeader("Cache-Control")}}, that prevents caching. +- The method used in the request is _cacheable_, that is either a {{HTTPMethod("GET")}} or a {{HTTPMethod("HEAD")}} method. A response to a {{HTTPMethod("POST")}} or {{HTTPMethod("PATCH")}} request can also be cached if freshness is indicated and the {{HTTPHeader("Content-Location")}} header is set, but this is rarely implemented. For example, Firefox does not support it ([Firefox bug 109553](https://bugzil.la/109553)). Other methods, like {{HTTPMethod("PUT")}} or {{HTTPMethod("DELETE")}} are not cacheable and their result cannot be cached. +- The status code of the response is _known_ by the application caching, and is _cacheable_. The following status codes are cacheable: {{HTTPStatus("200")}}, {{HTTPStatus("203")}}, {{HTTPStatus("204")}}, {{HTTPStatus("206")}}, {{HTTPStatus("300")}}, {{HTTPStatus("301")}}, {{HTTPStatus("404")}}, {{HTTPStatus("405")}}, {{HTTPStatus("410")}}, {{HTTPStatus("414")}}, and {{HTTPStatus("501")}}. +- There are no specific headers in the response, like {{HTTPHeader("Cache-Control")}}, with values that would prohibit caching. -Note that some non-cacheable requests/responses to a specific URI may invalidate previously cached responses on the same URI. For example, a {{HTTPMethod("PUT")}} to pageX.html will invalidate all cached {{HTTPMethod("GET")}} or {{HTTPMethod("HEAD")}} requests to the same URI. +Note that some requests with non-cacheable responses to a specific URI may invalidate previously cached responses from the same URI. For example, a {{HTTPMethod("PUT")}} to `/pageX.html` will invalidate all cached responses to {{HTTPMethod("GET")}} or {{HTTPMethod("HEAD")}} requests to `/pageX.html`. -When both, the method of the request and the status of the response, are cacheable, the response to the request can be cached: +When both the method of the request and the status of the response are cacheable, the response to the request can be cached: ```http GET /pageX.html HTTP/1.1 @@ -24,7 +24,7 @@ GET /pageX.html HTTP/1.1 (…) ``` -A {{HTTPMethod("PUT")}} request cannot be cached. Moreover, it invalidates cached data for request to the same URI done via {{HTTPMethod("HEAD")}} or {{HTTPMethod("GET")}}: +The response to a {{HTTPMethod("PUT")}} request cannot be cached. Moreover, it invalidates cached data for requests to the same URI using {{HTTPMethod("HEAD")}} or {{HTTPMethod("GET")}} methods: ```http PUT /pageX.html HTTP/1.1 @@ -34,7 +34,7 @@ PUT /pageX.html HTTP/1.1 (…) ``` -A specific {{HTTPHeader("Cache-Control")}} header in the response can prevent caching: +The presence of the {{HTTPHeader("Cache-Control")}} header with a particular value in the response can prevent caching: ```http GET /pageX.html HTTP/1.1 diff --git a/files/en-us/glossary/forbidden_header_name/index.md b/files/en-us/glossary/forbidden_header_name/index.md index 284bdedc4db527a..ca59da5a9cac37a 100644 --- a/files/en-us/glossary/forbidden_header_name/index.md +++ b/files/en-us/glossary/forbidden_header_name/index.md @@ -8,7 +8,7 @@ page-type: glossary-definition A **forbidden header name** is the name of any [HTTP header](/en-US/docs/Web/HTTP/Headers) that cannot be modified programmatically; specifically, an HTTP **request** header name (in contrast with a {{Glossary("Forbidden response header name")}}). -Modifying such headers is forbidden because the user agent retains full control over them. Names starting with `Sec-` are reserved for creating new headers safe from {{glossary("API","APIs")}} using the [fetch algorithm](https://fetch.spec.whatwg.org/#concept-fetch) that grant developers control over headers, such as {{domxref("XMLHttpRequest")}}. +Modifying such headers is forbidden because the user agent retains full control over them. Names starting with `Sec-` are reserved for creating new headers safe from {{glossary("API","APIs")}} that grant developers control over headers, such as {{domxref("fetch()")}}. Forbidden header names start with `Proxy-` or `Sec-`, or are one of the following names: diff --git a/files/en-us/glossary/grid_lines/index.md b/files/en-us/glossary/grid_lines/index.md index b1ac3be923ff6be..5c4c668965891fc 100644 --- a/files/en-us/glossary/grid_lines/index.md +++ b/files/en-us/glossary/grid_lines/index.md @@ -6,7 +6,7 @@ page-type: glossary-definition {{GlossarySidebar}} -**Grid lines** are created when you define {{glossary("Grid tracks", "tracks")}} in the explicit grid using [CSS Grid Layout](/en-US/docs/Web/CSS/CSS_grid_layout). +**Grid lines** are created anytime you use a [CSS Grid Layout](/en-US/docs/Web/CSS/CSS_grid_layout). ## Example diff --git a/files/en-us/glossary/houdini/index.md b/files/en-us/glossary/houdini/index.md index 3892425bee992e2..d1f9db5c290f1a4 100644 --- a/files/en-us/glossary/houdini/index.md +++ b/files/en-us/glossary/houdini/index.md @@ -14,7 +14,7 @@ While many of the features Houdini enables can be created with JavaScript, inter ## See also -- [Houdini](/en-US/docs/Web/Guide/Houdini) +- [Houdini APIs](/en-US/docs/Web/API/Houdini_APIs) - [CSSOM](/en-US/docs/Web/API/CSS_Object_Model) - [CSS Paint API](/en-US/docs/Web/API/CSS_Painting_API) - [CSS Typed OM](/en-US/docs/Web/API/CSS_Typed_OM_API) diff --git a/files/en-us/glossary/http/index.md b/files/en-us/glossary/http/index.md index 7a52735bdfa21c4..fc661808db22fed 100644 --- a/files/en-us/glossary/http/index.md +++ b/files/en-us/glossary/http/index.md @@ -10,7 +10,7 @@ The HyperText Transfer Protocol (**HTTP**) is the underlying network {{glossary( As part of a {{glossary("URI")}}, the "http" within "http\://example.com/" is called a "scheme". Resources using the "http" schema are typically transported over unencrypted connections using the HTTP protocol. The "https" scheme (as in "https\://developer.mozilla.org") indicates that a resource is transported using the HTTP protocol, but over a secure {{glossary("TLS")}} channel. -HTTP is textual (all communication is done in plain text) and stateless (no communication is aware of previous communications). This property makes it ideal for humans to read documents (websites) on the world wide web. However, HTTP can also be used as a basis for {{glossary("REST")}} web services from server to server or {{glossary("AJAX")}} requests within websites to make them more dynamic. +HTTP is textual (all communication is done in plain text) and stateless (no communication is aware of previous communications). This property makes it ideal for humans to read documents (websites) on the world wide web. However, HTTP can also be used as a basis for {{glossary("REST")}} web services from server to server or {{domxref("fetch()")}} requests within websites to make them more dynamic. ## See also diff --git a/files/en-us/glossary/input_method_editor/index.md b/files/en-us/glossary/input_method_editor/index.md index 9ca22a9f27edf75..6482ff4a6e3c3de 100644 --- a/files/en-us/glossary/input_method_editor/index.md +++ b/files/en-us/glossary/input_method_editor/index.md @@ -6,11 +6,11 @@ page-type: glossary-definition {{GlossarySidebar}} -An input method editor (IME) is a program that provides a specialized user interface for text input. Input method editors are used in many situations: +An Input Method Editor (IME) is a program that provides a specialized user interface for text input. Input method editors are used in many situations: -- to enter Chinese, Japanese, or Korean text using a Latin keyboard -- to enter Latin text using a numeric keypad -- to enter text on a touch screen using handwriting recognition +- To enter Chinese, Japanese, or Korean text using a Latin keyboard. +- To enter Latin text using a numeric keypad. +- To enter text on a touch screen using handwriting recognition. ## See also diff --git a/files/en-us/glossary/javascript/index.md b/files/en-us/glossary/javascript/index.md index 288f6a9e8ef1315..3f289767338a52c 100644 --- a/files/en-us/glossary/javascript/index.md +++ b/files/en-us/glossary/javascript/index.md @@ -10,7 +10,7 @@ JavaScript (or "JS") is a programming language used most often for dynamic clien JavaScript **should not** be confused with the [Java programming language](). Although _"Java"_ and _"JavaScript"_ are trademarks (or registered trademarks) of Oracle in the U.S. and other countries, the two programming languages are significantly different in their syntax, semantics, and use cases. -JavaScript is primarily used in the browser, enabling developers to manipulate webpage content through the {{Glossary("DOM")}}, manipulate data with {{Glossary("AJAX")}} and {{Glossary("IndexedDB")}}, draw graphics with {{Glossary("canvas")}}, interact with the device running the browser through various {{Glossary("API","APIs")}}, and more. JavaScript is one of the world's most commonly-used languages, owing to the recent growth and performance improvement of {{Glossary("API","APIs")}} available in browsers. +JavaScript is primarily used in the browser, enabling developers to manipulate webpage content through the {{Glossary("DOM")}}, retrieve content from servers using the {{domxref("fetch()")}} API, store complex data using {{Glossary("IndexedDB")}}, draw graphics with {{Glossary("canvas")}}, interact with the device running the browser through various {{Glossary("API","APIs")}}, and more. JavaScript is one of the world's most commonly-used languages, owing to the recent growth and performance improvement of {{Glossary("API","APIs")}} available in browsers. ## Origins and History diff --git a/files/en-us/glossary/media_query/index.md b/files/en-us/glossary/media_query/index.md new file mode 100644 index 000000000000000..6535a1398369a47 --- /dev/null +++ b/files/en-us/glossary/media_query/index.md @@ -0,0 +1,24 @@ +--- +title: Media query +slug: Glossary/Media_query +page-type: glossary-definition +--- + +{{GlossarySidebar}} + +A **media query** is a logical expression that is a method for CSS, JavaScript, HTML, and other web languages, to check aspects of the user agent or device that the document is being displayed in, independent of the document contents, to determine whether the associated code block or feature should be applied. + +Media queries are used to conditionally apply CSS styles with the CSS {{cssxref("@media")}} and {{cssxref("@import")}} at-rules and in JavaScript to test and monitor media states such as with the {{DOMxRef("Window.matchMedia", "matchMedia()")}} method, {{DOMxRef("MediaQueryList.matches", "matches")}} property, and {{DOMxRef("MediaQueryList.change_event", "change")}} event. Media queries are used as values of the [``](/en-US/docs/Web/HTML/Element/link#media), [``](/en-US/docs/Web/HTML/Element/source#media), and [` +

Hello world!

+

This is a test.

+ + + + + + +``` + +#### CSS + +```css +body { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 5px; +} + +textarea { + grid-column: 1 / span 3; +} +``` + +#### JavaScript + +```js +const copyButton = document.getElementById("copy"); +const pasteButton = document.getElementById("paste_normal"); +const pasteUnsanitizedButton = document.getElementById("paste_unsanitized"); +const sourceTextarea = document.getElementById("source"); +const destinationTextarea = document.getElementById("destination"); + +copyButton.addEventListener("click", async () => { + const text = sourceTextarea.value; + const type = "text/html"; + const blob = new Blob([text], { type }); + const data = [new ClipboardItem({ [type]: blob })]; + + try { + await navigator.clipboard.write(data); + } catch (error) { + destinationTextarea.value = `Clipboard write failed: ${error}`; + } +}); + +async function getHTMLFromClipboardContents(clipboardContents) { + for (const item of clipboardContents) { + if (item.types.includes("text/html")) { + const blob = await item.getType("text/html"); + const blobText = await blob.text(); + return blobText; + } + } + + return null; +} + +pasteButton.addEventListener("click", async () => { + try { + const clipboardContents = await navigator.clipboard.read(); + const html = await getHTMLFromClipboardContents(clipboardContents); + destinationTextarea.value = + html || "Could not find HTML data in the clipboard."; + } catch (error) { + destinationTextarea.value = `Clipboard read failed: ${error}`; + } +}); + +pasteUnsanitizedButton.addEventListener("click", async () => { + try { + const clipboardContents = await navigator.clipboard.read({ + unsanitized: ["text/html"], + }); + const html = await getHTMLFromClipboardContents(clipboardContents); + destinationTextarea.value = + html || "Could not find HTML data in the clipboard."; + } catch (error) { + destinationTextarea.value = `Clipboard read failed: ${error}`; + } +}); +``` + +#### Result + +First click the "Copy HTML" button to write the HTML code from the first textarea to the clipboard. Then either click the "Paste HTML" button or the "Paste unsanitized HTML" button to paste the sanitized or unsanitized HTML code into the second textarea. + +{{EmbedLiveSample("Reading unsanitized HTML from the clipboard", "100%", "220")}} ## Specifications @@ -118,5 +358,8 @@ async function pasteImage() { ## See also - [Clipboard API](/en-US/docs/Web/API/Clipboard_API) -- [Async Clipboard API demo on Glitch](https://async-clipboard-api.glitch.me/) -- [Image support for Async Clipboard article](https://web.dev/articles/async-clipboard) +- [Unblocking clipboard access](https://web.dev/articles/async-clipboard) on web.dev +- [Unsanitized HTML in the Async Clipboard API](https://developer.chrome.com/docs/web-platform/unsanitized-html-async-clipboard) on developer.chrome.com +- {{domxref("Clipboard.readText()")}} +- {{domxref("Clipboard.writeText()")}} +- {{domxref("Clipboard.write()")}} diff --git a/files/en-us/web/api/clipboard/readtext/index.md b/files/en-us/web/api/clipboard/readtext/index.md index 63ebc49055e1621..14a981fac4051ea 100644 --- a/files/en-us/web/api/clipboard/readtext/index.md +++ b/files/en-us/web/api/clipboard/readtext/index.md @@ -6,11 +6,12 @@ page-type: web-api-instance-method browser-compat: api.Clipboard.readText --- -{{APIRef("Clipboard API")}} +{{APIRef("Clipboard API")}} {{securecontext_header}} -The **{{domxref("Clipboard")}}** interface's -**`readText()`** method returns a {{jsxref("Promise")}} which -resolves with a copy of the textual contents of the system clipboard. +The **`readText()`** method of the {{domxref("Clipboard")}} interface returns a {{jsxref("Promise")}} which fulfils with a copy of the textual contents of the system clipboard. + +> **Note:** To read non-text contents from the clipboard, use the {{domxref("Clipboard.read", "read()")}} method instead. +> You can write text to the clipboard using {{domxref("Clipboard.writeText", "writeText()")}}. ## Syntax @@ -24,30 +25,34 @@ None. ### Return value -A {{jsxref("Promise")}} that resolves with a string containing the -textual contents of the clipboard. Returns an empty string if the clipboard is empty, -does not contain text, or does not include a textual representation among the -{{domxref("DataTransfer")}} objects representing the clipboard's contents. +A {{jsxref("Promise")}} that resolves with a string containing the textual contents of the clipboard. + +Returns an empty string if the clipboard is empty, does not contain text, or does not include a textual representation among the objects representing the clipboard's contents. + +### Exceptions -To read non-text contents from the clipboard, use the {{domxref("Clipboard.read", - "read()")}} method instead. You can write text to the clipboard using -{{domxref("Clipboard.writeText", "writeText()")}}. +- `NotAllowedError` {{domxref("DOMException")}} + - : Thrown if the access to read the clipboard is not allowed. +- `NotFoundError` {{domxref("DOMException")}} + - : Thrown if the clipboard indicates that it contains data that can be represented as a text but is unable to provide a textual representation. -## Security +## Security considerations -[Transient user activation](/en-US/docs/Web/Security/User_activation) is required. The user has to interact with the page or a UI element in order for this feature to work. +Reading from the clipboard can only be done in a [secure context](/en-US/docs/Web/Security/Secure_Contexts). -The `"clipboard-read"` permission of the [Permissions API](/en-US/docs/Web/API/Permissions_API) must be granted before you can read data from the clipboard. +Additional security requirements are covered in the [Security consideration](/en-US/docs/Web/API/Clipboard_API#security_considerations) section of the API overview topic. ## Examples -This example retrieves the textual contents of the clipboard and inserts the returned -text into an element's contents. +This example retrieves the textual contents of the clipboard and inserts the returned text into a selected element's contents. ```js -navigator.clipboard - .readText() - .then((clipText) => (document.getElementById("outbox").innerText = clipText)); +const destination = document.getElementById("outbox"); +destinationImage.addEventListener("click", () => { + navigator.clipboard + .readText() + .then((clipText) => (destination.innerText = clipText)); +}); ``` ## Specifications @@ -61,7 +66,7 @@ navigator.clipboard ## See also - [Clipboard API](/en-US/docs/Web/API/Clipboard_API) -- [Async Clipboard API demo on Glitch](https://async-clipboard-api.glitch.me/) - [Image support for Async Clipboard article](https://web.dev/articles/async-clipboard) +- {{domxref("Clipboard.read()")}} - {{domxref("Clipboard.writeText()")}} - {{domxref("Clipboard.write()")}} diff --git a/files/en-us/web/api/clipboard/write/index.md b/files/en-us/web/api/clipboard/write/index.md index 743ef1789618308..c2613a1edd400b1 100644 --- a/files/en-us/web/api/clipboard/write/index.md +++ b/files/en-us/web/api/clipboard/write/index.md @@ -6,21 +6,13 @@ page-type: web-api-instance-method browser-compat: api.Clipboard.write --- -{{APIRef("Clipboard API")}} +{{APIRef("Clipboard API")}} {{securecontext_header}} -The {{domxref("Clipboard")}} method -**`write()`** writes arbitrary data, such as images, to the -clipboard. This can be used to implement cut and copy functionality. +The **`write()`** method of the {{domxref("Clipboard")}} interface writes arbitrary data to the clipboard, such as images, fulfilling the returned {{jsxref("Promise")}} on completion. +This can be used to implement cut and copy functionality. -The `"clipboard-write"` permission of the [Permissions API](/en-US/docs/Web/API/Permissions_API), is granted -automatically to pages when they are in the active tab. - -> **Note:** Browser support for the asynchronous clipboard APIs is still -> in the process of being implemented. Be sure to check the [compatibility table](#browser_compatibility) as well as -> [Clipboard availability](/en-US/docs/Web/API/Clipboard#clipboard_availability) for more -> information. - -> **Note:** For parity with Google Chrome, Firefox only allows this function to work with text, HTML, and PNG data. +The method can in theory write arbitrary data (unlike {{domxref("Clipboard.writeText", "writeText()")}}, which can only write text). +Browsers commonly support writing text, HTML, and PNG image data — see [browser compatibility](#browser_compatibility) for more information. ## Syntax @@ -31,67 +23,73 @@ write(data) ### Parameters - `data` - - : An array of {{domxref("ClipboardItem")}} objects containing data to be written to - the clipboard. + - : An array of {{domxref("ClipboardItem")}} objects containing data to be written to the clipboard. ### Return value -A {{jsxref("Promise")}} which is resolved when the data has been written to the -clipboard. The promise is rejected if the clipboard is unable to complete the clipboard -access. +A {{jsxref("Promise")}} which is resolved when the data has been written to the clipboard. +Note that if the underlying OS does not support multiple native clipboard items on the system clipboard, then only the first {{domxref("ClipboardItem")}} in the array is written. + +The promise is rejected if the clipboard is unable to write to the clipboard. + +### Exceptions + +- `NotAllowedError` {{domxref("DOMException")}} + - : Thrown if writing to the clipboard is not allowed. + +## Security considerations + +Writing to the clipboard can only be done in a [secure context](/en-US/docs/Web/Security/Secure_Contexts). + +Additional security requirements are covered in the [Security consideration](/en-US/docs/Web/API/Clipboard_API#security_considerations) section of the API overview topic. ## Examples -This example function replaces the current contents of the clipboard with a specified -string. +### Write text to the clipboard + +This example function replaces the current contents of the clipboard with a specified string when a button is pressed. +Note that for this particular case, you could just as readily use `Clipboard.writeText()`. ```js -function setClipboard(text) { +button.addEventListener("click", setClipboard("")); + +async function setClipboard(text) { const type = "text/plain"; const blob = new Blob([text], { type }); const data = [new ClipboardItem({ [type]: blob })]; - - navigator.clipboard.write(data).then( - () => { - /* success */ - }, - () => { - /* failure */ - }, - ); + await navigator.clipboard.write(data); } ``` -The code begins by creating a new a {{domxref("Blob")}} object. This object is -required to construct a {{domxref("ClipboardItem")}} object which is sent to the -clipboard. The {{domxref("Blob")}} constructor takes in the content we want to copy -and its type. This {{domxref("Blob")}} object can be derived from many sources; for example, a [canvas](/en-US/docs/Web/API/HTMLCanvasElement). +The `setClipboard()` method begins by creating a new a {{domxref("Blob")}} object. +This object is required to construct a {{domxref("ClipboardItem")}} object which is sent to the clipboard. +The {{domxref("Blob")}} constructor takes in the content we want to copy and its type. +This {{domxref("Blob")}} object can be derived from many sources; for example, a [canvas](/en-US/docs/Web/API/HTMLCanvasElement). Next, we create a new {{domxref("ClipboardItem")}} object into which the blob will be placed for sending to the clipboard. -The key of the object passed to the {{domxref("ClipboardItem")}} constructor indicates the content type, the value indicates the content. Then `write()` is called, specifying both a fulfillment function -and an error function. +The key of the object passed to the {{domxref("ClipboardItem")}} constructor indicates the content type, the value indicates the content. +Then `write()` is called with `await`. +A `try..catch` block could be used to catch any errors writing the data. + +### Write canvas contents to the clipboard -### Example of copying canvas contents to the clipboard +This example writes the canvas to a blob, using the default MIME type of `image/png`, and then writes the blob to the clipboard. ```js -function copyCanvasContentsToClipboard(canvas, onDone, onError) { - canvas.toBlob((blob) => { - let data = [new ClipboardItem({ [blob.type]: blob })]; - - navigator.clipboard.write(data).then( - () => { - onDone(); - }, - (err) => { - onError(err); - }, - ); - }); +// Get canvas can add an event handler for the click event. +const canvas = document.getElementById("canvas"); +canvas.addEventListener("click", copyCanvasContentsToClipboard()); + +async function copyCanvasContentsToClipboard() { + // Copy canvas to blob + const blob = await canvas.toBlob(); + // Create ClipboardItem with blob and it's type, and add to an array + const data = [new ClipboardItem({ [blob.type]: blob })]; + // Write the data to the clipboard + await navigator.clipboard.write(data); } ``` -> **Note:** You can only pass in one clipboard item at a time. - ## Specifications {{Specifications}} @@ -103,5 +101,7 @@ function copyCanvasContentsToClipboard(canvas, onDone, onError) { ## See also - [Clipboard API](/en-US/docs/Web/API/Clipboard_API) -- [Async Clipboard API demo on Glitch](https://async-clipboard-api.glitch.me/) - [Image support for Async Clipboard article](https://web.dev/articles/async-clipboard) +- {{domxref("Clipboard.writeText()")}} +- {{domxref("Clipboard.read()")}} +- {{domxref("Clipboard.readText()")}} diff --git a/files/en-us/web/api/clipboard/writetext/index.md b/files/en-us/web/api/clipboard/writetext/index.md index 1212b2f57f5f1ea..1fa8c137dcace18 100644 --- a/files/en-us/web/api/clipboard/writetext/index.md +++ b/files/en-us/web/api/clipboard/writetext/index.md @@ -6,12 +6,9 @@ page-type: web-api-instance-method browser-compat: api.Clipboard.writeText --- -{{APIRef("Clipboard API")}} +{{APIRef("Clipboard API")}} {{securecontext_header}} -The {{domxref("Clipboard")}} interface's **`writeText()`** -property writes the specified text string to the system clipboard. Text may be read back -using either {{domxref("Clipboard.read", "read()")}} or {{domxref("Clipboard.readText", - "readText()")}}. +The **`writeText()`** method of the {{domxref("Clipboard")}} interface writes the specified text to the system clipboard, returning a {{jsxref("Promise")}} that is resolved once the system clipboard has been updated. ## Syntax @@ -26,29 +23,33 @@ writeText(newClipText) ### Return value -A {{jsxref("Promise")}} which is resolved once the clipboard's contents have been -updated. The promise is rejected if the caller does not have permission to write to the -clipboard. +A {{jsxref("Promise")}} that is resolved once the clipboard's contents have been updated. -## Security +### Exceptions -[Transient user activation](/en-US/docs/Web/Security/User_activation) is required. The user has to interact with the page or a UI element in order for this feature to work. +- `NotAllowedError` {{domxref("DOMException")}} + - : Thrown if writing to the clipboard is not allowed. -The `"clipboard-write"` permission of the [Permissions API](/en-US/docs/Web/API/Permissions_API) is granted automatically to pages when they are in the active tab. +## Security considerations + +Writing to the clipboard can only be done in a [secure context](/en-US/docs/Web/Security/Secure_Contexts). + +Additional security requirements are covered in the [Security consideration](/en-US/docs/Web/API/Clipboard_API#security_considerations) section of the API overview topic. ## Examples This example sets the clipboard's contents to the string "\". ```js -navigator.clipboard.writeText("").then( - () => { - /* clipboard successfully set */ - }, - () => { - /* clipboard write failed */ - }, -); +button.addEventListener("click", () => writeClipboardText("")); + +async function writeClipboardText(text) { + try { + await navigator.clipboard.writeText(text); + } catch (error) { + console.error(error.message); + } +} ``` ## Specifications @@ -62,5 +63,7 @@ navigator.clipboard.writeText("").then( ## See also - [Clipboard API](/en-US/docs/Web/API/Clipboard_API) -- [Async Clipboard API demo on Glitch](https://async-clipboard-api.glitch.me/) - [Image support for Async Clipboard article](https://web.dev/articles/async-clipboard) +- {{domxref("Clipboard.write()")}} +- {{domxref("Clipboard.read()")}} +- {{domxref("Clipboard.readText()")}} diff --git a/files/en-us/web/api/clipboard_api/index.md b/files/en-us/web/api/clipboard_api/index.md index 7d769ce005f5185..cbf20cda9a0c2f4 100644 --- a/files/en-us/web/api/clipboard_api/index.md +++ b/files/en-us/web/api/clipboard_api/index.md @@ -10,20 +10,91 @@ browser-compat: {{DefaultAPISidebar("Clipboard API")}} -The **Clipboard API** provides the ability to respond to clipboard commands (cut, copy, and paste) as well as to asynchronously read from and write to the system clipboard. +The **Clipboard API** provides the ability to respond to clipboard commands (cut, copy, and paste), as well as to asynchronously read from and write to the system clipboard. + +> **Note:** Use this API in preference to the deprecated {{domxref("document.execCommand()")}} method for accessing the clipboard. > **Note:** This API is _not available_ in [Web Workers](/en-US/docs/Web/API/Web_Workers_API) (not exposed via {{domxref("WorkerNavigator")}}). -This API is designed to supersede accessing the clipboard using {{domxref("document.execCommand()")}}. +## Concepts and usage + +The _system clipboard_ is a data buffer belonging to the operating system hosting the browser, which is used for short-term data storage and/or data transfers between documents or applications. +It is usually implemented as an anonymous, temporary [data buffer](https://en.wikipedia.org/wiki/Data_buffer), sometimes called the _paste buffer_, that can be accessed from most or all programs within the environment via defined programming interfaces. + +The Clipboard API allows users to programmatically read and write text and other kinds of data to and from the system clipboard in [secure contexts](/en-US/docs/Web/Security/Secure_Contexts), provided the user has met the criteria outlined in the [Security considerations](#security_considerations). + +Events are fired as the result of {{domxref("Element/cut_event", "cut")}}, {{domxref("Element/copy_event", "copy")}}, and {{domxref("Element/paste_event", "paste")}} operations modifying the clipboard. +The events have a default action, for example the `copy` action copies the current selection to the system clipboard by default. +The default action can be overriden by the event handler — see each of the events for more information. + +## Interfaces + +- {{domxref("Clipboard")}} {{securecontext_inline}} + - : Provides an interface for reading and writing text and data to or from the system clipboard. + The specification refers to this as the 'Async Clipboard API'. +- {{domxref("ClipboardEvent")}} + - : Represents events providing information related to modification of the clipboard, that is {{domxref("Element/cut_event", "cut")}}, {{domxref("Element/copy_event", "copy")}}, and {{domxref("Element/paste_event", "paste")}} events. + The specification refers to this as the 'Clipboard Event API'. +- {{domxref("ClipboardItem")}} {{securecontext_inline}} + - : Represents a single item format, used when reading or writing data. + +### Extensions to other interfaces + +The Clipboard API extends the following APIs, adding the listed features. + +- {{domxref("Navigator.clipboard")}} {{readonlyinline}} {{securecontext_inline}} + - : Returns a {{domxref("Clipboard")}} object that provides read and write access to the system clipboard. +- [`Element: copy`](/en-US/docs/Web/API/Element/copy_event) event + - : An event fired whenever the user initiates a copy action. +- [`Element: cut`](/en-US/docs/Web/API/Element/cut_event) event + - : An event fired whenever the user initiates a cut action. +- [`Element: paste`](/en-US/docs/Web/API/Element/paste_event) event + - : An event fired whenever the user initiates a paste action. + + + +## Security considerations + +The Clipboard API allows users to programmatically read and write text and other kinds of data to and from the system clipboard in [secure contexts](/en-US/docs/Web/Security/Secure_Contexts). -> **Note:** The **clipboard** is a data buffer that is used for short-term, data storage and/or data transfers, this can be between documents or applications. -> It is usually implemented as an anonymous, temporary [data buffer](https://en.wikipedia.org/wiki/Data_buffer), sometimes called the paste buffer, that can be accessed from most or all programs within the environment via defined [programming interfaces](https://en.wikipedia.org/wiki/Application_programming_interface). -> -> A typical application accesses clipboard functionality by mapping [user input](https://en.wikipedia.org/wiki/User_input) such as [keybindings](https://en.wikipedia.org/wiki/Keybinding), [menu selections](), etc. to these interfaces. +The specification requires that a user has recently interacted with the page in order to read from the clipboard ([transient user activation](/en-US/docs/Web/Security/User_activation) is required). +If the read operation is caused by user interaction with a browser or OS "paste element" (such as a context menu), the browser is expected to prompt the user for acknowledgement. +For writing to the clipboard the specification expects that the page has been granted the [Permissions API](/en-US/docs/Web/API/Permissions_API) `clipboard-write` permission, and the browser may also require [transient user activation](/en-US/docs/Web/Security/User_activation). +Browsers may place additional restrictions over use of the methods to access the clipboard. -## Accessing the clipboard +Browser implementations have diverged from the specification. +The differences are captured in the [Browser compatibility](#browser_compatibility) section and the current state is summarized below: -Instead of creating a `Clipboard` object through instantiation, you access the system clipboard through the {{domxref("Navigator.clipboard")}} global: +Chromium browsers: + +- Reading requires the [Permissions API](/en-US/docs/Web/API/Permissions_API) `clipboard-read` permission be granted. + Transient activation is not required. +- Writing requires either the `clipboard-read` permission or transient activation. + If the permission is granted, it persists, and further transient activation is not required. +- The HTTP [Permissions-Policy](/en-US/docs/Web/HTTP/Headers/Permissions-Policy) permissions `clipboard-read` and `clipboard-write` must be allowed for {{HTMLElement("iframe")}} elements that access the clipboard. +- No persistent paste-prompt is displayed when a read operation is caused by a browser or OS "paste element". + +Firefox & Safari: + +- Reading and writing require transient activation. +- The paste-prompt is suppressed if reading same-origin clipboard content, but not cross-origin content. +- The `clipboard-read` and `clipboard-write` permissions are not supported (and not planned to be supported) by Firefox or Safari. + +Firefox [Web Extensions](/en-US/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard): + +- Reading text is only available for extensions with the Web Extension [`clipboardRead`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#clipboardread) permission. + With this permission the extension does not require transient activation or a paste prompt. +- Writing text is available in secure context and with transient activation. + With the Web Extension [`clipboardWrite`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions#clipboardwrite) permission transient activation is not required. + +## Examples + +### Accessing the clipboard + +The system clipboard is accessed through the {{domxref("Navigator.clipboard")}} global. + +This snippet fetches the text from the clipboard and appends it to the first element found with the class `editor`. +Since {{domxref("Clipboard.readText", "readText()")}} (and {{domxref("Clipboard.read", "read()")}}, for that matter) returns an empty string if the clipboard isn't text, this code is safe. ```js navigator.clipboard @@ -33,17 +104,6 @@ navigator.clipboard ); ``` -This snippet fetches the text from the clipboard and appends it to the first element found with the class `editor`. Since {{domxref("Clipboard.readText", "readText()")}} (and {{domxref("Clipboard.read", "read()")}}, for that matter) returns an empty string if the clipboard isn't text, this code is safe. - -## Interfaces - -- {{domxref("Clipboard")}} {{securecontext_inline}} - - : Provides an interface for reading and writing text and data to or from the system clipboard. The specification refers to this as the 'Async Clipboard API'. -- {{domxref("ClipboardEvent")}} - - : Represents events providing information related to modification of the clipboard, that is {{domxref("Element/cut_event", "cut")}}, {{domxref("Element/copy_event", "copy")}}, and {{domxref("Element/paste_event", "paste")}} events. The specification refers to this as the 'Clipboard Event API'. -- {{domxref("ClipboardItem")}} {{securecontext_inline}} - - : Represents a single item format, used when reading or writing data. - ## Specifications {{Specifications}} @@ -54,5 +114,4 @@ This snippet fetches the text from the clipboard and appends it to the first ele ## See also -- [Async Clipboard API demo on Glitch](https://async-clipboard-api.glitch.me/) - [Image support for Async Clipboard article](https://web.dev/articles/async-clipboard) diff --git a/files/en-us/web/api/clipboardevent/clipboarddata/index.md b/files/en-us/web/api/clipboardevent/clipboarddata/index.md index 68bfe307bf0607a..fd2fb95269df3a3 100644 --- a/files/en-us/web/api/clipboardevent/clipboarddata/index.md +++ b/files/en-us/web/api/clipboardevent/clipboarddata/index.md @@ -8,16 +8,12 @@ browser-compat: api.ClipboardEvent.clipboardData {{APIRef("Clipboard API")}} -The **`ClipboardEvent.clipboardData`** property holds a {{domxref("DataTransfer")}} object, which can be used: +The **`clipboardData`** property of the {{domxref("ClipboardEvent")}} interface holds a {{domxref("DataTransfer")}} object, which can be used to: -- to specify what data should be put into the clipboard from the {{domxref("Element/cut_event", "cut")}} and - {{domxref("Element/copy_event", "copy")}} event handlers, typically with a {{domxref("DataTransfer.setData", - "setData(format, data)")}} call; -- to obtain the data to be pasted from the {{domxref("Element/paste_event", "paste")}} event handler, typically - with a {{domxref("DataTransfer.getData", "getData(format)")}} call. +- specify what data should be put into the clipboard from the {{domxref("Element/cut_event", "cut")}} and {{domxref("Element/copy_event", "copy")}} event handlers, typically with a {{domxref("DataTransfer.setData", "setData(format, data)")}} call; +- obtain the data to be pasted from the {{domxref("Element/paste_event", "paste")}} event handler, typically with a {{domxref("DataTransfer.getData", "getData(format)")}} call. -See the {{domxref("Element/cut_event", "cut")}}, {{domxref("Element/copy_event", "copy")}}, and {{domxref("Element/paste_event", "paste")}} events -documentation for more information. +See the {{domxref("Element/cut_event", "cut")}}, {{domxref("Element/copy_event", "copy")}}, and {{domxref("Element/paste_event", "paste")}} events documentation for more information. ## Value diff --git a/files/en-us/web/api/clipboardevent/clipboardevent/index.md b/files/en-us/web/api/clipboardevent/clipboardevent/index.md index bd83f7c3d7f5476..a082297e8220313 100644 --- a/files/en-us/web/api/clipboardevent/clipboardevent/index.md +++ b/files/en-us/web/api/clipboardevent/clipboardevent/index.md @@ -8,10 +8,7 @@ browser-compat: api.ClipboardEvent.ClipboardEvent {{APIRef("Clipboard API")}} -The **`ClipboardEvent()`** constructor returns a new {{domxref("ClipboardEvent")}}, -representing an event providing information related to modification of the clipboard, -that is {{domxref("Element/cut_event", "cut")}}, {{domxref("Element/copy_event", "copy")}}, and -{{domxref("Element/paste_event", "paste")}} events. +The **`ClipboardEvent()`** constructor returns a new {{domxref("ClipboardEvent")}}, representing an event providing information related to modification of the clipboard, that is {{domxref("Element/cut_event", "cut")}}, {{domxref("Element/copy_event", "copy")}}, and {{domxref("Element/paste_event", "paste")}} events. ## Syntax diff --git a/files/en-us/web/api/clipboardevent/index.md b/files/en-us/web/api/clipboardevent/index.md index 43f914be407fd43..a3ece80eadd2e63 100644 --- a/files/en-us/web/api/clipboardevent/index.md +++ b/files/en-us/web/api/clipboardevent/index.md @@ -7,7 +7,7 @@ browser-compat: api.ClipboardEvent {{APIRef("Clipboard API")}} -The **`ClipboardEvent`** interface represents events providing information related to modification of the clipboard, that is {{domxref("Element/cut_event", "cut")}}, {{domxref("Element/copy_event", "copy")}}, and {{domxref("Element/paste_event", "paste")}} events. +The **`ClipboardEvent`** interface of the [Clipboard API](/en-US/docs/Web/API/Clipboard_API) represents events providing information related to modification of the clipboard, that is {{domxref("Element/cut_event", "cut")}}, {{domxref("Element/copy_event", "copy")}}, and {{domxref("Element/paste_event", "paste")}} events. {{InheritanceDiagram}} @@ -39,5 +39,4 @@ _No specific methods; inherits methods from its parent {{domxref("Event")}}_. - Copy-related events: {{domxref("Element/copy_event", "copy")}}, {{domxref("Element/cut_event", "cut")}}, {{domxref("Element/paste_event", "paste")}} - [Clipboard API](/en-US/docs/Web/API/Clipboard_API) -- [Async Clipboard API demo on Glitch](https://async-clipboard-api.glitch.me/) - [Image support for Async Clipboard article](https://web.dev/articles/async-clipboard) diff --git a/files/en-us/web/api/clipboarditem/clipboarditem/index.md b/files/en-us/web/api/clipboarditem/clipboarditem/index.md index b55e707d2522b36..23e03b2ec95339e 100644 --- a/files/en-us/web/api/clipboarditem/clipboarditem/index.md +++ b/files/en-us/web/api/clipboarditem/clipboarditem/index.md @@ -6,9 +6,9 @@ page-type: web-api-constructor browser-compat: api.ClipboardItem.ClipboardItem --- -{{APIRef("Clipboard API")}} +{{APIRef("Clipboard API")}} {{securecontext_header}} -The **`ClipboardItem()`** constructor of the {{domxref("Clipboard API")}} creates a new {{domxref("ClipboardItem")}} object which represents data to be stored or retrieved via the {{domxref("Clipboard API")}}, that is {{domxref("clipboard.write()")}} and {{domxref("clipboard.read()")}} respectively. +The **`ClipboardItem()`** constructor creates a new {{domxref("ClipboardItem")}} object, which represents data to be stored or retrieved via the [Clipboard API](/en-US/docs/Web/API/Clipboard_API) {{domxref("clipboard.write()")}} and {{domxref("clipboard.read()")}} methods, respectively. > **Note:** Image format support varies by browser. See the browser compatibility table for the {{domxref("Clipboard")}} interface. @@ -22,18 +22,20 @@ new ClipboardItem(data, options) ### Parameters - `data` - - : An {{jsxref("Object")}} with the {{Glossary("MIME type")}} as the key and data as the value. The data can be represented as a {{domxref("Blob")}}, a {{jsxref("String")}} or a {{jsxref("Promise")}} which resolves to either a blob or string. + - : An {{jsxref("Object")}} with the {{Glossary("MIME type")}} as the key and data as the value. + The data can be represented as a {{domxref("Blob")}}, a {{jsxref("String")}} or a {{jsxref("Promise")}} which resolves to either a blob or string. - `options` {{optional_inline}} - : An object with the following properties: - `presentationStyle` {{optional_inline}} - - : One of the three strings: `unspecified`, `inline` or `attachment`. The default is `unspecified`. + - : One of the three strings: `unspecified`, `inline` or `attachment`. + The default is `unspecified`. -> **Note:** You can also work with text via the {{domxref("Clipboard.readText()")}} and {{domxref("Clipboard.writeText()")}} methods of the {{domxref("Clipboard")}} -> interface. +> **Note:** You can also work with text via the {{domxref("Clipboard.readText()")}} and {{domxref("Clipboard.writeText()")}} methods of the {{domxref("Clipboard")}} interface. ## Examples -The below example requests a png image using the {{domxref("Fetch API")}}, and in turn, the {{domxref("Response.blob()", "responses' blob()")}} method, to create a new {{domxref("ClipboardItem")}}. This item is then written to the clipboard, using the {{domxref("Clipboard.write()")}} method. +The below example requests a PNG image using the {{domxref("Fetch API")}}, and in turn, the {{domxref("Response.blob()", "responses' blob()")}} method, to create a new {{domxref("ClipboardItem")}}. +This item is then written to the clipboard, using the {{domxref("Clipboard.write()")}} method. > **Note:** You can only pass in one clipboard item at a time. @@ -67,5 +69,4 @@ async function writeClipImg() { ## See also - [Clipboard API](/en-US/docs/Web/API/Clipboard_API) -- [Async Clipboard API demo on Glitch](https://async-clipboard-api.glitch.me/) - [Image support for Async Clipboard article](https://web.dev/articles/async-clipboard) diff --git a/files/en-us/web/api/clipboarditem/gettype/index.md b/files/en-us/web/api/clipboarditem/gettype/index.md index fea9f779fac4a04..bdf857c9a5a4e44 100644 --- a/files/en-us/web/api/clipboarditem/gettype/index.md +++ b/files/en-us/web/api/clipboarditem/gettype/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.ClipboardItem.getType --- -{{APIRef("Clipboard API")}} +{{APIRef("Clipboard API")}} {{securecontext_header}} The **`getType()`** method of the {{domxref("ClipboardItem")}} interface returns a {{jsxref("Promise")}} that resolves with a {{domxref("Blob")}} of the requested {{Glossary("MIME type")}} or an error if the MIME type is not found. @@ -30,15 +30,12 @@ A {{jsxref("Promise")}} that resolves with a {{domxref("Blob")}} object. - `NotFoundError` {{domxref("DOMException")}} - : The `type` does not match a known {{Glossary("MIME type")}}. - {{jsxref("TypeError")}} - - : No parameter is specified or the `type` is not that of the - {{domxref("ClipboardItem")}}. + - : No parameter is specified or the `type` is not that of the {{domxref("ClipboardItem")}}. ## Examples -In the following example, we're returning all items on the clipboard via the -{{domxref("clipboard.read()")}} method. Then utilizing the -{{domxref("ClipboardItem.types")}} property to set the `getType()` argument -and return the corresponding blob object. +In the following example, we're returning all items on the clipboard via the {{domxref("clipboard.read()")}} method. +Then utilizing the {{domxref("ClipboardItem.types")}} property to set the `getType()` argument and return the corresponding blob object. ```js async function getClipboardContents() { @@ -68,5 +65,4 @@ async function getClipboardContents() { ## See also - [Clipboard API](/en-US/docs/Web/API/Clipboard_API) -- [Async Clipboard API demo on Glitch](https://async-clipboard-api.glitch.me/) - [Image support for Async Clipboard article](https://web.dev/articles/async-clipboard) diff --git a/files/en-us/web/api/clipboarditem/index.md b/files/en-us/web/api/clipboarditem/index.md index e7f6fb9bf3cc177..87a5aec9f08c697 100644 --- a/files/en-us/web/api/clipboarditem/index.md +++ b/files/en-us/web/api/clipboarditem/index.md @@ -7,16 +7,12 @@ browser-compat: api.ClipboardItem {{APIRef("Clipboard API")}}{{SecureContext_Header}} -The **`ClipboardItem`** interface of the {{domxref('Clipboard API')}} represents a single item format, used when reading or writing data via the {{domxref('Clipboard API')}}. That is {{domxref("clipboard.read()")}} and {{domxref("clipboard.write()")}} respectively. +The **`ClipboardItem`** interface of the [Clipboard API](/en-US/docs/Web/API/Clipboard_API) represents a single item format, used when reading or writing clipboard data using {{domxref("clipboard.read()")}} and {{domxref("clipboard.write()")}} respectively. -The benefit of having the **`ClipboardItem`** interface to represent data, is that it enables developers to cope with the varying scope of file types and data easily. - -Access to the contents of the clipboard is gated behind the [Permissions API](/en-US/docs/Web/API/Permissions_API): The `clipboard-write` permission is granted automatically to pages when they are in the active tab. The `clipboard-read` permission must be requested, which you can do by trying to read data from the clipboard. +The benefit of having the **`ClipboardItem`** interface to represent data, is that it enables developers to cope with the varying scope of file types and data. > **Note:** To work with text see the {{domxref("Clipboard.readText()")}} and {{domxref("Clipboard.writeText()")}} methods of the {{domxref("Clipboard")}} interface. -> **Note:** You can only pass in one clipboard item at a time. - ## Constructor - {{domxref("ClipboardItem.ClipboardItem", "ClipboardItem()")}} @@ -40,9 +36,9 @@ _This interface defines the following methods._ ## Examples -### Writing To Clipboard +### Writing to the clipboard -Here we're writing a new {{domxref("ClipboardItem.ClipboardItem", "ClipboardItem()")}} to the {{domxref("Clipboard API", "clipboard")}} by requesting a png image using the {{domxref("Fetch API")}}, and in turn, the {{domxref("Response.blob()", "responses' blob()")}} method, to create the new {{domxref("ClipboardItem")}}. +Here we're writing a new {{domxref("ClipboardItem.ClipboardItem", "ClipboardItem()")}} to the system clipboard by requesting a PNG image using the {{domxref("Fetch API")}}, and in turn, the {{domxref("Response.blob()", "responses' blob()")}} method, to create the new `ClipboardItem`. ```js async function writeClipImg() { @@ -63,9 +59,10 @@ async function writeClipImg() { } ``` -### Reading From The Clipboard +### Reading from the clipboard -Here we're returning all items on the clipboard via the {{domxref("clipboard.read()")}} method. Then utilizing the {{domxref("ClipboardItem.types")}} property to set the {{domxref("ClipboardItem.getType", "getType()")}} argument and return the corresponding blob object. +Here we're returning all items on the clipboard via the {{domxref("clipboard.read()")}} method. +Then utilizing the {{domxref("ClipboardItem.types")}} property to set the {{domxref("ClipboardItem.getType", "getType()")}} argument and return the corresponding blob object. ```js async function getClipboardContents() { @@ -95,5 +92,4 @@ async function getClipboardContents() { ## See also - [Clipboard API](/en-US/docs/Web/API/Clipboard_API) -- [Async Clipboard API demo on Glitch](https://async-clipboard-api.glitch.me/) - [Image support for Async Clipboard article](https://web.dev/articles/async-clipboard) diff --git a/files/en-us/web/api/clipboarditem/presentationstyle/index.md b/files/en-us/web/api/clipboarditem/presentationstyle/index.md index 1e07dcee7237aa7..3304cdd1b2f73c9 100644 --- a/files/en-us/web/api/clipboarditem/presentationstyle/index.md +++ b/files/en-us/web/api/clipboarditem/presentationstyle/index.md @@ -6,11 +6,11 @@ page-type: web-api-instance-property browser-compat: api.ClipboardItem.presentationStyle --- -{{APIRef("Clipboard API")}} +{{APIRef("Clipboard API")}} {{securecontext_header}} -The read-only -**`presentationStyle`** property of the {{domxref("ClipboardItem")}} -interface returns a string indicating how an item should be presented. +The read-only **`presentationStyle`** property of the {{domxref("ClipboardItem")}} interface returns a string indicating how an item should be presented. + +For example, in some contexts an image might be displayed inline, while in others it might be represented as an attachment. ## Value @@ -45,5 +45,4 @@ async function getClipboardContents() { ## See also - [Clipboard API](/en-US/docs/Web/API/Clipboard_API) -- [Async Clipboard API demo on Glitch](https://async-clipboard-api.glitch.me/) - [Image support for Async Clipboard article](https://web.dev/articles/async-clipboard) diff --git a/files/en-us/web/api/clipboarditem/types/index.md b/files/en-us/web/api/clipboarditem/types/index.md index ca35b6d4afae157..4b823e3a8ec5ab5 100644 --- a/files/en-us/web/api/clipboarditem/types/index.md +++ b/files/en-us/web/api/clipboarditem/types/index.md @@ -6,12 +6,9 @@ page-type: web-api-instance-property browser-compat: api.ClipboardItem.types --- -{{APIRef("Clipboard API")}} +{{APIRef("Clipboard API")}} {{securecontext_header}} -The read-only -**`types`** property of the {{domxref("ClipboardItem")}} -interface returns an {{jsxref("Array")}} of {{Glossary("MIME type", 'MIME types')}} -available within the {{domxref("ClipboardItem")}} +The read-only **`types`** property of the {{domxref("ClipboardItem")}} interface returns an {{jsxref("Array")}} of {{Glossary("MIME type", 'MIME types')}} available within the {{domxref("ClipboardItem")}} ## Value @@ -19,11 +16,8 @@ An {{jsxref("Array")}} of available {{Glossary("MIME type", 'MIME types')}}. ## Examples -In the below example, we're returning all items on the clipboard via the -{{domxref("clipboard.read()")}} method. Then checking the `types` property -for available types before utilizing the {{domxref("ClipboardItem.getType()")}} method -to return the {{domxref("Blob")}} object. If no clipboards contents is found for the -specified type, an error is returned. +In the below example, we're returning all items on the clipboard via the {{domxref("Clipboard.read()")}} method. +Then checking the `types` property for available types before utilizing the {{domxref("ClipboardItem.getType()")}} method to return the {{domxref("Blob")}} object. If no clipboards contents is found for the specified type, an error is returned. ```js async function getClipboardContents() { @@ -53,5 +47,4 @@ async function getClipboardContents() { ## See also - [Clipboard API](/en-US/docs/Web/API/Clipboard_API) -- [Async Clipboard API demo on Glitch](https://async-clipboard-api.glitch.me/) - [Image support for Async Clipboard article](https://web.dev/articles/async-clipboard) diff --git a/files/en-us/web/api/compositionevent/index.md b/files/en-us/web/api/compositionevent/index.md index 77c62151947b1c2..46347b9aa704326 100644 --- a/files/en-us/web/api/compositionevent/index.md +++ b/files/en-us/web/api/compositionevent/index.md @@ -23,7 +23,7 @@ _This interface also inherits properties of its parent, {{domxref("UIEvent")}}, - {{domxref("CompositionEvent.data")}} {{ReadOnlyInline}} - : Returns the characters generated by the input method that raised the event; its varies depending on the type of event that generated the `CompositionEvent` object. - {{domxref("CompositionEvent.locale")}} {{ReadOnlyInline}} {{deprecated_inline}} {{Non-standard_Inline}} - - : Returns the locale of current input method (for example, the keyboard layout locale if the composition is associated with IME). + - : Returns the locale of current input method (for example, the keyboard layout locale if the composition is associated with {{glossary("IME")}}). ## Instance methods diff --git a/files/en-us/web/api/compositionevent/locale/index.md b/files/en-us/web/api/compositionevent/locale/index.md index 75867cc440a2f79..ec8fe12acd402d3 100644 --- a/files/en-us/web/api/compositionevent/locale/index.md +++ b/files/en-us/web/api/compositionevent/locale/index.md @@ -13,7 +13,7 @@ browser-compat: api.CompositionEvent.locale The **`locale`** read-only property of the {{domxref("CompositionEvent")}} interface returns the locale of current input method -(for example, the keyboard layout locale if the composition is associated with IME). +(for example, the keyboard layout locale if the composition is associated with {{glossary("IME")}}). > **Warning:** Even for browsers supporting it, don't trust the value contained in this property. > Even if technically it is accessible, the way to set it up when creating a {{domxref("CompositionEvent")}} diff --git a/files/en-us/web/api/console/index.md b/files/en-us/web/api/console/index.md index 666c264d12e7470..178f8da4f330e13 100644 --- a/files/en-us/web/api/console/index.md +++ b/files/en-us/web/api/console/index.md @@ -76,7 +76,10 @@ This page documents the [Methods](#methods) available on the `console` object an The console's most frequently used feature is logging text and other data. There are several categories of output you can generate using the {{domxref("console/log_static", "console.log()")}}, {{domxref("console/info_static", "console.info()")}}, {{domxref("console/warn_static", "console.warn()")}}, {{domxref("console/error_static", "console.error()")}}, or {{domxref("console/debug_static", "console.debug()")}} methods. Each of these results in output styled differently in the log, and you can use the filtering controls provided by your browser to view only the kinds of output that interest you. -There are two ways to use each of the output methods; you can pass in a list of objects whose string representations get concatenated into one string, then output to the console, or you can pass in a string containing zero or more substitution strings followed by a list of objects to replace them. +There are two ways to use each of the output methods: + +- Pass in a variable number of arguments whose string representations get concatenated into one string, then output to the console. +- Pass in a string containing zero or more substitution strings followed by a variable number of arguments to replace them. #### Outputting a single object @@ -89,7 +92,7 @@ console.log(someObject); The output looks something like this: -```bash +```plain {str:"Some text", id:5} ``` @@ -105,7 +108,7 @@ console.info("My first car was a", car, ". The object is:", someObject); The output will look like this: -```bash +```plain My first car was a Dodge Charger. The object is: {str:"Some text", id:5} ``` diff --git a/files/en-us/web/api/contactaddress/addressline/index.md b/files/en-us/web/api/contactaddress/addressline/index.md new file mode 100644 index 000000000000000..1fd9ba889e36e5a --- /dev/null +++ b/files/en-us/web/api/contactaddress/addressline/index.md @@ -0,0 +1,42 @@ +--- +title: "ContactAddress: addressLine property" +short-title: addressLine +slug: Web/API/ContactAddress/addressLine +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.ContactAddress.addressLine +--- + +{{securecontext_header}}{{APIRef("Contact Picker API")}}{{SeeCompatTable}} + +The **`addressLine`** read-only property of the {{domxref("ContactAddress")}} interface is an array of strings, each specifying a line of the address that is not covered by one of the other properties of `ContactAddress`. The array may include the street name, the house number, apartment number, the rural delivery route, descriptive instructions, or the post office box. + +## Value + +An array of strings, each containing one line of the address. For example, the `addressLine` property for the Mozilla Space in London would have the following entries: + +| Index | addressLine[] value | +| ----- | ------------------------- | +| 0 | Metal Box Factory | +| 1 | Suite 441, 4th floor | +| 2 | 30 Great Guildford Street | + +These, combined with additional values for other properties of the {{domxref("ContactAddress")}}, would represent the full address, which is: + +```plaintext +Mozilla +Metal Box Factory +Suite 441, 4th floor +30 Great Guildford Street +London SE1 0HS +United Kingdom +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/contactaddress/city/index.md b/files/en-us/web/api/contactaddress/city/index.md new file mode 100644 index 000000000000000..b53c236aa2884b0 --- /dev/null +++ b/files/en-us/web/api/contactaddress/city/index.md @@ -0,0 +1,25 @@ +--- +title: "ContactAddress: city property" +short-title: city +slug: Web/API/ContactAddress/city +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.ContactAddress.city +--- + +{{securecontext_header}}{{APIRef("Contact Picker API")}}{{SeeCompatTable}} + +The **`city`** read-only property of the {{domxref("ContactAddress")}} interface returns a string containing the city or town portion of the address. + +## Value + +A string indicating the city or town portion of the address described by the {{domxref("ContactAddress")}} object. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/contactaddress/country/index.md b/files/en-us/web/api/contactaddress/country/index.md new file mode 100644 index 000000000000000..96a0f75a6820706 --- /dev/null +++ b/files/en-us/web/api/contactaddress/country/index.md @@ -0,0 +1,27 @@ +--- +title: "ContactAddress: country property" +short-title: country +slug: Web/API/ContactAddress/country +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.ContactAddress.country +--- + +{{securecontext_header}}{{APIRef("Contact Picker API")}}{{SeeCompatTable}} + +The **`country`** read-only property of the {{domxref("ContactAddress")}} interface is a string identifying the address's country using the [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) standard. The string is always in its canonical upper-case form. + +Some examples of valid `country` values: `"US"`, `"GB"`, `"CN"`, or `"JP"`. + +## Value + +A string which contains the ISO3166-1 alpha-2 code identifying the country in which the address is located, or an empty string if no country is available, which frequently can be assumed to mean "same country as the site owner." + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/contactaddress/dependentlocality/index.md b/files/en-us/web/api/contactaddress/dependentlocality/index.md new file mode 100644 index 000000000000000..9b1e7572747836f --- /dev/null +++ b/files/en-us/web/api/contactaddress/dependentlocality/index.md @@ -0,0 +1,27 @@ +--- +title: "ContactAddress: dependentLocality property" +short-title: dependentLocality +slug: Web/API/ContactAddress/dependentLocality +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.ContactAddress.dependentLocality +--- + +{{securecontext_header}}{{APIRef("Contact Picker API")}}{{SeeCompatTable}} + +The read-only **`dependentLocality`** property of the {{domxref("ContactAddress")}} interface is a string containing a locality or sublocality designation within a city, such as a neighborhood, borough, district, or, in the United Kingdom, a dependent locality. Also known as a _post town_. + +## Value + +A string indicating the sublocality portion of the address. This may be an empty string if no sublocality is available or required. It's used to provide disambiguation when a city may include areas that duplicate street names. + +A sublocality is an area within a city, such as a neighborhood, borough, or district. In the United Kingdom, this is used to indicate the **post town** in the United Kingdom (known officially by the Royal Mail as the **dependent locality**). This is a disambiguating feature of addresses in places where a city may have areas that duplicate street names. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/contactaddress/index.md b/files/en-us/web/api/contactaddress/index.md index f2119ed365d398e..be5f84be7cf58b3 100644 --- a/files/en-us/web/api/contactaddress/index.md +++ b/files/en-us/web/api/contactaddress/index.md @@ -7,19 +7,39 @@ status: browser-compat: api.ContactAddress --- -{{securecontext_header}}{{APIRef("")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Contact Picker API")}}{{SeeCompatTable}} -The **`ContactAddress`** interface of the {{domxref('contact_picker_api','Contact Picker API','','true')}} represents a physical address. Instances of this interface are retrieved from the `address` property of the objects returned by {{domxref("ContactsManager.getProperties()")}}. +The **`ContactAddress`** interface of the [Contact Picker API](/en-US/docs/Web/API/Contact_Picker_API) represents a physical address. Instances of this interface are retrieved from the `address` property of the objects returned by {{domxref("ContactsManager.getProperties()")}}. It may be useful to refer to the Universal Postal Union website's [Addressing S42 standard](https://www.upu.int/en/Postal-Solutions/Programmes-Services/Addressing-Solutions#addressing-s42-standard) materials, which provide information about international standards for postal addresses. ## Instance properties -_Inherits properties from its parent, {{domxref("PaymentAddress")}}_. +- {{domxref('ContactAddress.addressLine')}} {{ReadOnlyInline}} {{experimental_inline}} + - : An array of strings providing each line of the address not included among the other properties. The exact size and content varies by country or location and can include, for example, a street name, house number, apartment number, rural delivery route, descriptive instructions, or post office box number. +- {{domxref('ContactAddress.country')}} {{ReadOnlyInline}} {{experimental_inline}} + - : A string specifying the country in which the address is located, using the [ISO-3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) standard. The string is always given in its canonical upper-case form. Some examples of valid `country` values: `"US"`, `"GB"`, `"CN"`, or `"JP"`. +- {{domxref('ContactAddress.city')}} {{ReadOnlyInline}} {{experimental_inline}} + - : A string which contains the city or town portion of the address. +- {{domxref('ContactAddress.dependentLocality')}} {{ReadOnlyInline}} {{experimental_inline}} + - : A string giving the dependent locality or sublocality within a city, for example, a neighborhood, borough, district, or UK dependent locality. +- {{domxref('ContactAddress.organization')}} {{ReadOnlyInline}} {{experimental_inline}} + - : A string specifying the name of the organization, firm, company, or institution at the address. +- {{domxref('ContactAddress.phone')}} {{ReadOnlyInline}} {{experimental_inline}} + - : A string specifying the telephone number of the recipient or contact person. +- {{domxref('ContactAddress.postalCode')}} {{ReadOnlyInline}} {{experimental_inline}} + - : A string specifying a code used by a jurisdiction for mail routing, for example, the ZIP code in the United States or the PIN code in India. +- {{domxref('ContactAddress.recipient')}} {{ReadOnlyInline}} {{experimental_inline}} + - : A string giving the name of the recipient, purchaser, or contact person at the address. +- {{domxref('ContactAddress.region')}} {{ReadOnlyInline}} {{experimental_inline}} + - : A string containing the top level administrative subdivision of the country, for example a state, province, oblast, or prefecture. +- {{domxref('ContactAddress.sortingCode')}} {{ReadOnlyInline}} {{experimental_inline}} + - : A string providing a postal sorting code such as is used in France. ## Instance methods -_Inherits methods from its parent, {{domxref("PaymentAddress")}}_. +- {{domxref('ContactAddress.toJSON()')}} {{experimental_inline}} + - : A standard serializer that returns a JSON representation of the `ContactAddress` object's properties. ## Examples diff --git a/files/en-us/web/api/contactaddress/organization/index.md b/files/en-us/web/api/contactaddress/organization/index.md new file mode 100644 index 000000000000000..42586b4f295777d --- /dev/null +++ b/files/en-us/web/api/contactaddress/organization/index.md @@ -0,0 +1,25 @@ +--- +title: "ContactAddress: organization property" +short-title: organization +slug: Web/API/ContactAddress/organization +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.ContactAddress.organization +--- + +{{securecontext_header}}{{APIRef("Contact Picker API")}}{{SeeCompatTable}} + +The **`organization`** read-only property of the {{domxref("ContactAddress")}} interface returns a string containing the name of the organization, firm, company, or institution at the address. + +## Value + +A string whose value is the name of the organization or company located at the address described by the `ContactAddress` object. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/contactaddress/phone/index.md b/files/en-us/web/api/contactaddress/phone/index.md new file mode 100644 index 000000000000000..97e155c2d72b146 --- /dev/null +++ b/files/en-us/web/api/contactaddress/phone/index.md @@ -0,0 +1,25 @@ +--- +title: "ContactAddress: phone property" +short-title: phone +slug: Web/API/ContactAddress/phone +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.ContactAddress.phone +--- + +{{securecontext_header}}{{APIRef("Contact Picker API")}}{{SeeCompatTable}} + +The read-only **`phone`** property of the {{domxref("ContactAddress")}} interface returns a string containing the telephone number of the recipient or contact person at the address. + +## Value + +A string containing the telephone number for the recipient of the shipment. If no phone number is available, this value is an empty string. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/contactaddress/postalcode/index.md b/files/en-us/web/api/contactaddress/postalcode/index.md new file mode 100644 index 000000000000000..92573d4839010af --- /dev/null +++ b/files/en-us/web/api/contactaddress/postalcode/index.md @@ -0,0 +1,31 @@ +--- +title: "ContactAddress: postalCode property" +short-title: postalCode +slug: Web/API/ContactAddress/postalCode +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.ContactAddress.postalCode +--- + +{{securecontext_header}}{{APIRef("Contact Picker API")}}{{SeeCompatTable}} + +The **`postalCode`** read-only property of the {{domxref("ContactAddress")}} interface returns a string containing a code used by a jurisdiction for mail routing, for example, the [ZIP Code](https://en.wikipedia.org/wiki/ZIP_Code) in the United States or the [Postal Index Number](https://en.wikipedia.org/wiki/Postal_Index_Number) (PIN code) in India. + +## Value + +A string which contains the postal code portion of the address. A postal code is a string (either numeric or alphanumeric) which is used by a postal service to optimize mail routing and delivery. + +Various countries use different terms for this. In most of the world, it's known as the "post code" or "postal code". In the United States, the ZIP code is used. India uses PIN codes. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- Universal Postal Union: [Universal Post\*Code® Database](https://www.upu.int/en/Postal-Solutions/Programmes-Services/Addressing-Solutions) diff --git a/files/en-us/web/api/contactaddress/recipient/index.md b/files/en-us/web/api/contactaddress/recipient/index.md new file mode 100644 index 000000000000000..c1ff75ee5945449 --- /dev/null +++ b/files/en-us/web/api/contactaddress/recipient/index.md @@ -0,0 +1,25 @@ +--- +title: "ContactAddress: recipient property" +short-title: recipient +slug: Web/API/ContactAddress/recipient +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.ContactAddress.recipient +--- + +{{securecontext_header}}{{APIRef("Contact Picker API")}}{{SeeCompatTable}} + +The read-only **`recipient`** property of the {{domxref("ContactAddress")}} interface returns a string containing the name of the recipient, purchaser, or contact person at the address. + +## Value + +A string giving the name of the person=, or the name of a contact person in other contexts. If no name is available, this string is empty. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/contactaddress/region/index.md b/files/en-us/web/api/contactaddress/region/index.md new file mode 100644 index 000000000000000..e7dc789167b4ccf --- /dev/null +++ b/files/en-us/web/api/contactaddress/region/index.md @@ -0,0 +1,29 @@ +--- +title: "ContactAddress: region property" +short-title: region +slug: Web/API/ContactAddress/region +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.ContactAddress.region +--- + +{{securecontext_header}}{{APIRef("Contact Picker API")}}{{SeeCompatTable}} + +The read-only **`region`** property of the {{domxref("ContactAddress")}} interface returns a string containing the top-level administrative subdivision of the country in which the address is located. This may be a state, province, oblast, or prefecture. + +## Value + +A string specifying the top-level administrative subdivision within the country in which the address is located. This region has different names in different countries, such as: state, province, oblast, prefecture, or county. + +## Usage notes + +In some countries, like Belgium, it's uncommon for people to provide a region as part of their postal address. In such cases, the browser returns an empty string as the value of `region`. However, the address should still be acceptable to use for its intended purpose (e.g., to ship a product). However, always verify addresses to make sure what the user provides is usable. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/contactaddress/sortingcode/index.md b/files/en-us/web/api/contactaddress/sortingcode/index.md new file mode 100644 index 000000000000000..ed59de2063e7d7f --- /dev/null +++ b/files/en-us/web/api/contactaddress/sortingcode/index.md @@ -0,0 +1,25 @@ +--- +title: "ContactAddress: sortingCode property" +short-title: sortingCode +slug: Web/API/ContactAddress/sortingCode +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.ContactAddress.sortingCode +--- + +{{securecontext_header}}{{APIRef("Contact Picker API")}}{{SeeCompatTable}} + +The **`sortingCode`** read-only property of the {{domxref("ContactAddress")}} interface returns a string containing a postal sorting code such as is used in France. + +## Value + +A string containing the sorting code portion of the address. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/contactaddress/tojson/index.md b/files/en-us/web/api/contactaddress/tojson/index.md new file mode 100644 index 000000000000000..83002d2dc6e0b38 --- /dev/null +++ b/files/en-us/web/api/contactaddress/tojson/index.md @@ -0,0 +1,31 @@ +--- +title: "ContactAddress: toJSON() method" +short-title: toJSON() +slug: Web/API/ContactAddress/toJSON +page-type: web-api-instance-method +status: + - experimental +browser-compat: api.ContactAddress.toJSON +--- + +{{securecontext_header}}{{APIRef("Contact Picker API")}}{{SeeCompatTable}} + +The **`toJSON()`** method of the {{domxref("ContactAddress")}} interface is a standard serializer that returns a JSON representation of the `ContactAddress` object's properties. + +## Syntax + +```js-nolint +toJSON() +``` + +### Return value + +A JSON object. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/cookie_store_api/index.md b/files/en-us/web/api/cookie_store_api/index.md index 0c1a9eb897f85ac..fdc91057902617f 100644 --- a/files/en-us/web/api/cookie_store_api/index.md +++ b/files/en-us/web/api/cookie_store_api/index.md @@ -2,14 +2,17 @@ title: Cookie Store API slug: Web/API/Cookie_Store_API page-type: web-api-overview -status: - - experimental -browser-compat: api.CookieStore +browser-compat: + - api.CookieStore + - api.CookieStoreManager +spec-urls: https://wicg.github.io/cookie-store/ --- -{{securecontext_header}}{{DefaultAPISidebar("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{DefaultAPISidebar("Cookie Store API")}} -The _**Cookie Store API**_ provides an asynchronous API for managing cookies, while also exposing cookies to [Service Worker API](/en-US/docs/Web/API/Service_Worker_API), +The **Cookie Store API** is an asynchronous API for managing cookies, available in windows and also [service workers](/en-US/docs/Web/API/Service_Worker_API). + +{{AvailableInWorkers}} ## Concepts and Usage @@ -21,14 +24,25 @@ The _Cookie Store API_ provides an updated method of managing cookies. It is {{G ## Interfaces -- {{domxref("CookieStore")}} +- {{domxref("CookieStore")}} {{Experimental_Inline}} - : The `CookieStore` interface enables getting and setting cookies. -- {{domxref("CookieStoreManager")}} +- {{domxref("CookieStoreManager")}} {{Experimental_Inline}} - : The `CookieStoreManager` interface provides a service worker registration to enable service workers to subscribe to cookie change events. -- {{domxref("CookieChangeEvent")}} +- {{domxref("CookieChangeEvent")}} {{Experimental_Inline}} - : A `CookieChangeEvent` named `change` is dispatched against `CookieStore` objects in {{domxref("Window")}} contexts when any script-visible cookies changes occur. - {{domxref("ExtendableCookieChangeEvent")}} - - : An `ExtendableCookieChangeEvent` named `change` is dispatched against {{domxref("ServiceWorkerGlobalScope")}} events when any script-visible cookie changes occur that match the service worker's cookie change subscription list. + - : An `ExtendableCookieChangeEvent` named `cookiechange` is dispatched in {{domxref("ServiceWorkerGlobalScope")}} contexts when any script-visible cookie changes occur that match the service worker's cookie change subscription list. + +### Extensions to other interfaces + +- {{domxref("ServiceWorkerGlobalScope.cookieStore")}} {{ReadOnlyInline}} {{Experimental_Inline}} + - : Returns a reference to the {{domxref("CookieStore")}} object associated with the service worker. +- {{domxref("ServiceWorkerRegistration.cookies")}} {{ReadOnlyInline}} {{Experimental_Inline}} + - : Returns a reference to the {{domxref("CookieStoreManager")}} interface, which enables a web app to subscribe to and unsubscribe from cookie change events. +- {{domxref("Window.cookieStore")}} {{ReadOnlyInline}} {{Experimental_Inline}} + - : Returns a reference to the {{domxref("CookieStore")}} object for the current document context. +- {{domxref("ServiceWorkerGlobalScope/cookiechange_event", "cookiechange")}} event {{Experimental_Inline}} + - : Fired when any cookie changes have occurred which match the service worker's cookie change subscription list. ## Specifications @@ -37,3 +51,7 @@ The _Cookie Store API_ provides an updated method of managing cookies. It is {{G ## Browser compatibility {{Compat}} + +## See also + +- [Service Worker API](/en-US/docs/Web/API/Service_Worker_API) diff --git a/files/en-us/web/api/cookiechangeevent/changed/index.md b/files/en-us/web/api/cookiechangeevent/changed/index.md index 202125d5725cf3d..d6b9176d2e4dd26 100644 --- a/files/en-us/web/api/cookiechangeevent/changed/index.md +++ b/files/en-us/web/api/cookiechangeevent/changed/index.md @@ -3,12 +3,10 @@ title: "CookieChangeEvent: changed property" short-title: changed slug: Web/API/CookieChangeEvent/changed page-type: web-api-instance-property -status: - - experimental browser-compat: api.CookieChangeEvent.changed --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}} The **`changed`** read-only property of the {{domxref("CookieChangeEvent")}} interface returns an array of the cookies that have been changed. @@ -25,7 +23,7 @@ An array of objects containing the changed cookie(s). Each object contains the f - `path` - : A string containing the path of the cookie. - `expires` - - : A timestamp, given as [Unix time](/en-US/docs/Glossary/Unix_time) in milliseconds, containing the expiration date of the cookie. + - : A timestamp, given as {{glossary("Unix time")}} in milliseconds, containing the expiration date of the cookie. - `secure` - : A {{jsxref("boolean")}} indicating whether the cookie is from a site with a secure context (HTTPS rather than HTTP). - `sameSite` @@ -39,9 +37,12 @@ An array of objects containing the changed cookie(s). Each object contains the f - `"none"` - : Cookies will be sent in all contexts. +- `partitioned` + - : A boolean indicating whether the cookie is a partitioned cookie (`true`) or not (`false`). See [Cookies Having Independent Partitioned State (CHIPS)](/en-US/docs/Web/Privacy/Partitioned_cookies) for more information. + ## Examples -In this example when the cookie is set, the event listener logs the `changed` property to the console. The first item in that array contains an object representing the cookie that has just been set. +In this example, when the cookie is set, the event listener logs the `changed` property to the console. The first item in that array contains an object representing the cookie that has just been set. ```js cookieStore.addEventListener("change", (event) => { diff --git a/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md b/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md index eeb08e89884436b..ee763d0c731e8ab 100644 --- a/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md +++ b/files/en-us/web/api/cookiechangeevent/cookiechangeevent/index.md @@ -3,15 +3,13 @@ title: "CookieChangeEvent: CookieChangeEvent() constructor" short-title: CookieChangeEvent() slug: Web/API/CookieChangeEvent/CookieChangeEvent page-type: web-api-constructor -status: - - experimental browser-compat: api.CookieChangeEvent.CookieChangeEvent --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}} The **`CookieChangeEvent()`** constructor creates a new {{domxref("CookieChangeEvent")}} object -which is the event type passed to {{domxref("CookieStore/change_event", "CookieStore.onchange()")}}. +which is the event type of the {{domxref("CookieStore/change_event", "change")}} event fired at a {{domxref("CookieStore")}} when any cookie changes occur. This constructor is called by the browser when a change event occurs. > **Note:** This event constructor is generally not needed for production websites. It's primary use is for tests that require an instance of this event. @@ -26,13 +24,12 @@ new CookieChangeEvent(type, options) ### Parameters - `type` - - : A string with the name of the event. - It is case-sensitive and browsers always set it to `cookiechange`. + - : A string with the name of the event. It is case-sensitive and browsers always set it to `change`. - `options` {{Optional_Inline}} - : An object that, _in addition of the properties defined in {{domxref("Event/Event", "Event()")}}_, can have the following properties: - - `changed` + - `changed`{{Optional_Inline}} - : An array containing the changed cookies. - - `deleted` + - `deleted`{{Optional_Inline}} - : An array containing the deleted cookies. ### Return value diff --git a/files/en-us/web/api/cookiechangeevent/deleted/index.md b/files/en-us/web/api/cookiechangeevent/deleted/index.md index b129e5d2a90cd5b..05a159871d0e225 100644 --- a/files/en-us/web/api/cookiechangeevent/deleted/index.md +++ b/files/en-us/web/api/cookiechangeevent/deleted/index.md @@ -3,12 +3,10 @@ title: "CookieChangeEvent: deleted property" short-title: deleted slug: Web/API/CookieChangeEvent/deleted page-type: web-api-instance-property -status: - - experimental browser-compat: api.CookieChangeEvent.deleted --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}} The **`deleted`** read-only property of the {{domxref("CookieChangeEvent")}} interface returns an array of the cookies that have been deleted by the given `CookieChangeEvent` instance. @@ -25,7 +23,7 @@ An array of objects containing the deleted cookie(s). Each object contains the f - `path` - : A string containing the path of the cookie. - `expires` - - : A timestamp, given as [Unix time](/en-US/docs/Glossary/Unix_time) in milliseconds, containing the expiration date of the cookie. + - : A timestamp, given as {{glossary("Unix time")}} in milliseconds, containing the expiration date of the cookie. - `secure` - : A {{jsxref("boolean")}} indicating whether the cookie is from a site with a secure context (HTTPS rather than HTTP). - `sameSite` @@ -39,9 +37,12 @@ An array of objects containing the deleted cookie(s). Each object contains the f - `"none"` - : Cookies will be sent in all contexts. +- `partitioned` + - : A boolean indicating whether the cookie is a partitioned cookie (`true`) or not (`false`). See [Cookies Having Independent Partitioned State (CHIPS)](/en-US/docs/Web/Privacy/Partitioned_cookies) for more information. + ## Examples -In this example when the cookie is deleted the event listener logs the first item in the `CookieChangeEvent.deleted` property to the console. It contains an object representing the cookie that has just been deleted. +In this example, when the cookie is deleted, the event listener logs the first item in the `CookieChangeEvent.deleted` property to the console. It contains an object representing the cookie that has just been deleted. ```js cookieStore.addEventListener("change", (event) => { diff --git a/files/en-us/web/api/cookiechangeevent/index.md b/files/en-us/web/api/cookiechangeevent/index.md index 6f0130249ef9b99..5deef4734f13f76 100644 --- a/files/en-us/web/api/cookiechangeevent/index.md +++ b/files/en-us/web/api/cookiechangeevent/index.md @@ -2,19 +2,17 @@ title: CookieChangeEvent slug: Web/API/CookieChangeEvent page-type: web-api-interface -status: - - experimental browser-compat: api.CookieChangeEvent --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}} -The **`CookieChangeEvent`** interface of the ['Cookie Store API'](/en-US/docs/Web/API/Cookie_Store_API) is the event type of the {{domxref("CookieStore.change_event", "change")}} event fired at a {{domxref("CookieStore")}} when any cookie changes occur. A cookie change consists of a cookie and a type (either "changed" or "deleted"). +The **`CookieChangeEvent`** interface of the {{domxref("Cookie Store API", "", "", "nocode")}} is the event type of the {{domxref("CookieStore/change_event", "change")}} event fired at a {{domxref("CookieStore")}} when any cookie changes occur. A cookie change consists of a cookie and a type (either "changed" or "deleted"). Cookie changes that will cause the `CookieChangeEvent` to be dispatched are: - A cookie is newly created and not immediately removed. In this case `type` is "changed". -- A cookie is newly created and immediately removed. In this case `type` is "deleted" +- A cookie is newly created and immediately removed. In this case `type` is "deleted". - A cookie is removed. In this case `type` is "deleted". > **Note:** A cookie that is replaced due to the insertion of another cookie with the same name, domain, and path, is ignored and does not trigger a change event. @@ -23,18 +21,22 @@ Cookie changes that will cause the `CookieChangeEvent` to be dispatched are: ## Constructor -- {{domxref("CookieChangeEvent.CookieChangeEvent", "CookieChangeEvent()")}} {{Experimental_Inline}} +- {{domxref("CookieChangeEvent.CookieChangeEvent", "CookieChangeEvent()")}} - : Creates a new `CookieChangeEvent`. ## Instance properties _This interface also inherits properties from {{domxref("Event")}}._ -- {{domxref("CookieChangeEvent.changed")}} {{ReadOnlyInline}} {{Experimental_Inline}} +- {{domxref("CookieChangeEvent.changed")}} {{ReadOnlyInline}} - : Returns an array containing one or more changed cookies. -- {{domxref("CookieChangeEvent.deleted")}} {{ReadOnlyInline}} {{Experimental_Inline}} +- {{domxref("CookieChangeEvent.deleted")}} {{ReadOnlyInline}} - : Returns an array containing one or more deleted cookies. +## Instance methods + +_This interface also inherits methods from {{domxref("Event")}}._ + ## Examples In this example when the cookie is set, the event listener logs the event to the console. This is a `CookieChangeEvent` object with the {{domxref("CookieChangeEvent.changed","changed")}} property containing an object representing the cookie that has just been set. diff --git a/files/en-us/web/api/cookiestore/change_event/index.md b/files/en-us/web/api/cookiestore/change_event/index.md index 9ffb29511d1b491..63d6ad76dede5d4 100644 --- a/files/en-us/web/api/cookiestore/change_event/index.md +++ b/files/en-us/web/api/cookiestore/change_event/index.md @@ -3,12 +3,10 @@ title: "CookieStore: change event" short-title: change slug: Web/API/CookieStore/change_event page-type: web-api-event -status: - - experimental browser-compat: api.CookieStore.change_event --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}} A `change` event is fired at a {{domxref("CookieStore")}} object when a change is made to any cookie. @@ -22,6 +20,12 @@ cookieStore.addEventListener("change", (event) => { }) cookieStore.onchange = (event) => { } ``` +## Event type + +A {{domxref("CookieChangeEvent")}}. Inherits from {{domxref("Event")}}. + +{{InheritanceDiagram("CookieChangeEvent")}} + ## Examples To be informed when a cookie has changed, you can add a handler to the `cookieStore` instance using {{domxref("EventTarget.addEventListener", "addEventListener()")}}, like this: @@ -32,7 +36,7 @@ cookieStore.addEventListener("change", (event) => { }); ``` -Alternatively, you can use the `CookieStore.onchange` event handler property to establish a handler for the `change` event: +Alternatively, you can use the `onchange` event handler property to establish a handler for the `change` event: ```js cookieStore.onchange = (event) => { diff --git a/files/en-us/web/api/cookiestore/delete/index.md b/files/en-us/web/api/cookiestore/delete/index.md index f2696999bd101d0..97994e893836e01 100644 --- a/files/en-us/web/api/cookiestore/delete/index.md +++ b/files/en-us/web/api/cookiestore/delete/index.md @@ -3,15 +3,15 @@ title: "CookieStore: delete() method" short-title: delete() slug: Web/API/CookieStore/delete page-type: web-api-instance-method -status: - - experimental browser-compat: api.CookieStore.delete --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}} The **`delete()`** method of the {{domxref("CookieStore")}} interface deletes a cookie with the given name or options object. The `delete()` method expires the cookie by changing the date to one in the past. +{{AvailableInWorkers}} + ## Syntax ```js-nolint @@ -23,23 +23,23 @@ delete(options) This method requires one of the following: -- `name` +- `name` {{optional_inline}} - : A string with the name of a cookie. Or -- `options` +- `options` {{optional_inline}} - : An object containing: - `name` - : A string with the name of a cookie. + - `domain` {{Optional_Inline}} + - : A string with the domain of a cookie. Defaults to `null`. + - `path` {{Optional_Inline}} + - : A string containing a path. Defaults to `/`. - `partitioned` {{Optional_Inline}} - : A boolean value that defaults to `false`. Setting it to `true` specifies that the cookie to delete will be a partitioned cookie. See [Cookies Having Independent Partitioned State (CHIPS)](/en-US/docs/Web/Privacy/Partitioned_cookies) for more information. - - `path` {{Optional_Inline}} - - : A string containing a path. - - `url` {{Optional_Inline}} - - : A string with the URL of a cookie. > **Note:** The `url` option enables the modification of a cookie scoped under a particular URL. Service workers can obtain cookies that would be sent to any URL under their scope. From a document you may only obtain the cookies at the current URL, so the only valid URL in a document context is the document's URL. @@ -49,6 +49,8 @@ A {{jsxref("Promise")}} that resolves with {{jsxref("undefined")}} when deletion ### Exceptions +- `SecurityError` {{domxref("DOMException")}} + - : Thrown if the origin can not be {{glossary("Serialization", "serialized")}} to a URL. - {{jsxref("TypeError")}} - : Thrown if deleting the cookie represented by the given `name` or `options` fails. diff --git a/files/en-us/web/api/cookiestore/get/index.md b/files/en-us/web/api/cookiestore/get/index.md index e82c7066d8fb4f2..6712bc182b71f8d 100644 --- a/files/en-us/web/api/cookiestore/get/index.md +++ b/files/en-us/web/api/cookiestore/get/index.md @@ -3,15 +3,15 @@ title: "CookieStore: get() method" short-title: get() slug: Web/API/CookieStore/get page-type: web-api-instance-method -status: - - experimental browser-compat: api.CookieStore.get --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}} The **`get()`** method of the {{domxref("CookieStore")}} interface returns a single cookie with the given name or options object. The method will return the first matching cookie for the passed parameters. +{{AvailableInWorkers}} + ## Syntax ```js-nolint @@ -23,12 +23,12 @@ get(options) This method requires one of the following: -- `name` +- `name` {{optional_inline}} - : A string with the name of a cookie. Or -- `options` +- `options` {{optional_inline}} - : An object containing: @@ -49,7 +49,7 @@ A {{jsxref("Promise")}} that resolves with an object representing the first cook - `expires` - - : A timestamp, given as [Unix time](/en-US/docs/Glossary/Unix_time) in milliseconds, containing the expiration date of the cookie. + - : A timestamp, given as {{glossary("Unix time")}} in milliseconds, containing the expiration date of the cookie. - `name` @@ -83,8 +83,14 @@ A {{jsxref("Promise")}} that resolves with an object representing the first cook ### Exceptions +- `SecurityError` {{domxref("DOMException")}} + - : Thrown if the origin does not {{glossary("Serialization", "serialize")}} to a URL. - {{jsxref("TypeError")}} - - : Thrown if getting the cookie represented by the given `name` or `options` fails. + - : Thrown if: + - The `options` parameter is an empty object. + - The `url` option is present and is not equal with the creation URL, if in main thread. + - The `url` option is present and its origin is not the same as the origin of the creation URL. + - Querying cookies represented by the given `name` or `options` fails. ## Examples diff --git a/files/en-us/web/api/cookiestore/getall/index.md b/files/en-us/web/api/cookiestore/getall/index.md index 05629f4cea4a8ea..61071b4eee8c74a 100644 --- a/files/en-us/web/api/cookiestore/getall/index.md +++ b/files/en-us/web/api/cookiestore/getall/index.md @@ -3,15 +3,15 @@ title: "CookieStore: getAll() method" short-title: getAll() slug: Web/API/CookieStore/getAll page-type: web-api-instance-method -status: - - experimental browser-compat: api.CookieStore.getAll --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}} The **`getAll()`** method of the {{domxref("CookieStore")}} interface returns a list of cookies that match the name or options passed to it. Passing no parameters will return all cookies for the current context. +{{AvailableInWorkers}} + ## Syntax ```js-nolint @@ -83,8 +83,13 @@ Each object contains the following properties: ### Exceptions +- `SecurityError` {{domxref("DOMException")}} + - : Thrown if the origin does not {{glossary("Serialization", "serialize")}} to a URL. - {{jsxref("TypeError")}} - - : Thrown if getting the cookie or cookies represented by the given `name` or `options` fails. + - : Thrown if: + - The `url` option is present and is not equal with the creation URL, if in main thread. + - The `url` option is present and its origin is not the same as the origin of the creation URL. + - Querying cookies represented by the given `name` or `options` fails. ## Examples diff --git a/files/en-us/web/api/cookiestore/index.md b/files/en-us/web/api/cookiestore/index.md index 562457e13f31742..9fccfc5b66f70bc 100644 --- a/files/en-us/web/api/cookiestore/index.md +++ b/files/en-us/web/api/cookiestore/index.md @@ -2,33 +2,33 @@ title: CookieStore slug: Web/API/CookieStore page-type: web-api-interface -status: - - experimental browser-compat: api.CookieStore --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}} -The **`CookieStore`** interface of the ['Cookie Store API'](/en-US/docs/Web/API/Cookie_Store_API) provides methods for getting and setting cookies asynchronously from either a page or a service worker. +The **`CookieStore`** interface of the {{domxref("Cookie Store API", "", "", "nocode")}} provides methods for getting and setting cookies asynchronously from either a page or a service worker. The `CookieStore` is accessed via attributes in the global scope in a {{domxref("Window")}} or {{domxref("ServiceWorkerGlobalScope")}} context. Therefore there is no constructor. {{InheritanceDiagram}} +{{AvailableInWorkers}} + ## Instance methods -- {{domxref("CookieStore.delete()")}} {{Experimental_Inline}} +- {{domxref("CookieStore.delete()")}} - : The `delete()` method deletes a cookie with the given name or options object, it returns a {{jsxref("Promise")}} that resolves when the deletion completes. -- {{domxref("CookieStore.get()")}} {{Experimental_Inline}} +- {{domxref("CookieStore.get()")}} - : The `get()` method gets a single cookie with the given name or options object, it returns a {{jsxref("Promise")}} that resolves with details of a single cookie. -- {{domxref("CookieStore.getAll()")}} {{Experimental_Inline}} +- {{domxref("CookieStore.getAll()")}} - : The `getAll()` method gets all matching cookies, it returns a {{jsxref("Promise")}} that resolves with a list of cookies. -- {{domxref("CookieStore.set()")}} {{Experimental_Inline}} +- {{domxref("CookieStore.set()")}} - : The `set()` method sets a cookie with the given name and value or options object, it returns a {{jsxref("Promise")}} that resolves when the cookie is set. ## Events -- {{domxref("CookieStore.change_event", "change")}} {{Experimental_Inline}} +- {{domxref("CookieStore.change_event", "change")}} - : The `change` event fires when a change is made to any cookie. ## Examples @@ -37,6 +37,7 @@ In this example, we set a cookie and write to the console feedback as to whether ```js const day = 24 * 60 * 60 * 1000; + cookieStore .set({ name: "cookie1", diff --git a/files/en-us/web/api/cookiestore/set/index.md b/files/en-us/web/api/cookiestore/set/index.md index 5e1066d6d0fad18..693a9f56d84ff1b 100644 --- a/files/en-us/web/api/cookiestore/set/index.md +++ b/files/en-us/web/api/cookiestore/set/index.md @@ -3,15 +3,15 @@ title: "CookieStore: set() method" short-title: set() slug: Web/API/CookieStore/set page-type: web-api-instance-method -status: - - experimental browser-compat: api.CookieStore.set --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}} The **`set()`** method of the {{domxref("CookieStore")}} interface sets a cookie with the given name and value or options object. +{{AvailableInWorkers}} + ## Syntax ```js-nolint @@ -23,33 +23,33 @@ set(options) This method requires one of the following: -- `name` +- `name` {{optional_inline}} - : A string with the name of the cookie. -- `value` +- `value` {{optional_inline}} - : A string with the value of the cookie. Or -- `options` +- `options` {{optional_inline}} - : An object containing: - `domain` {{Optional_Inline}} - - : A string containing the domain of the cookie. + - : A string containing the domain of the cookie. Defaults to `null`. - `expires` {{Optional_Inline}} - - : A timestamp, given as [Unix time](/en-US/docs/Glossary/Unix_time) in milliseconds, containing the expiration date of the cookie. + - : A timestamp, given as {{glossary("Unix time")}} in milliseconds, containing the expiration date of the cookie. Defaults to `null`. - `name` - : A string with the name of a cookie. - `partitioned` {{Optional_Inline}} - : A boolean value that defaults to `false`. If set to `true`, the set cookie will be a partitioned cookie. See [Cookies Having Independent Partitioned State (CHIPS)](/en-US/docs/Web/Privacy/Partitioned_cookies) for more information. - `path` {{Optional_Inline}} - - : A string containing the path of the cookie. + - : A string containing the path of the cookie. Defaults to `/`. - `sameSite` {{Optional_Inline}} - : One of the following [`SameSite`](/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value) values: - `"strict"` - - : Cookies will only be sent in a first-party context and not be sent along with requests initiated by third party websites. + - : Cookies will only be sent in a first-party context and not be sent along with requests initiated by third party websites. This is the default. - `"lax"` - : Cookies are not sent on normal cross-site subrequests (for example to load images or frames into a third party site), but are sent when a user is navigating to the origin site (i.e. when following a link). - `"none"` @@ -64,10 +64,10 @@ A {{jsxref("Promise")}} that resolves with {{jsxref("undefined")}} when setting ### Exceptions -- {{jsxref("TypeError")}} - - : Thrown if setting the cookie with the given values fails. - `SecurityError` {{domxref("DOMException")}} - - : Thrown if the origin does not {{glossary("Serialization", "serialize")}} to a URL. + - : Thrown if the origin can not be {{glossary("Serialization", "serialized")}} to a URL. +- {{jsxref("TypeError")}} + - : Thrown if setting the cookie with the given `name` and `value` or `options` fails. ## Examples diff --git a/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md b/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md index 39661690c38f789..01fdf3b600bda4a 100644 --- a/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md +++ b/files/en-us/web/api/cookiestoremanager/getsubscriptions/index.md @@ -3,12 +3,10 @@ title: "CookieStoreManager: getSubscriptions() method" short-title: getSubscriptions() slug: Web/API/CookieStoreManager/getSubscriptions page-type: web-api-instance-method -status: - - experimental browser-compat: api.CookieStoreManager.getSubscriptions --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}} The **`getSubscriptions()`** method of the {{domxref("CookieStoreManager")}} interface returns a list of all the cookie change subscriptions for this {{domxref("ServiceWorkerRegistration")}}. diff --git a/files/en-us/web/api/cookiestoremanager/index.md b/files/en-us/web/api/cookiestoremanager/index.md index 8de3343f034d12f..3895fc0f10275ab 100644 --- a/files/en-us/web/api/cookiestoremanager/index.md +++ b/files/en-us/web/api/cookiestoremanager/index.md @@ -2,12 +2,10 @@ title: CookieStoreManager slug: Web/API/CookieStoreManager page-type: web-api-interface -status: - - experimental browser-compat: api.CookieStoreManager --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}} The **`CookieStoreManager`** interface of the {{domxref("Cookie Store API", "", "", "nocode")}} allows service workers to subscribe to cookie change events. Call {{domxref("CookieStoreManager.subscribe()","subscribe()")}} on a particular service worker registration to receive change events. @@ -19,11 +17,11 @@ To get a `CookieStoreManager`, call {{domxref("ServiceWorkerRegistration.cookies ## Instance methods -- {{domxref("CookieStoreManager.getSubscriptions()")}} {{Experimental_Inline}} +- {{domxref("CookieStoreManager.getSubscriptions()")}} - : Returns a {{jsxref("Promise")}} which resolves to a list of the cookie change subscriptions for this service worker registration. -- {{domxref("CookieStoreManager.subscribe()")}} {{Experimental_Inline}} +- {{domxref("CookieStoreManager.subscribe()")}} - : Subscribes to changes to cookies. It returns a {{jsxref("Promise")}} which resolves when the subscription is successful. -- {{domxref("CookieStoreManager.unsubscribe()")}} {{Experimental_Inline}} +- {{domxref("CookieStoreManager.unsubscribe()")}} - : Unsubscribes the registered service worker from changes to cookies. It returns a {{jsxref("Promise")}} which resolves when the operation is successful. ## Examples diff --git a/files/en-us/web/api/cookiestoremanager/subscribe/index.md b/files/en-us/web/api/cookiestoremanager/subscribe/index.md index 2bd1cb2676991b8..6f45ea927c3bb5a 100644 --- a/files/en-us/web/api/cookiestoremanager/subscribe/index.md +++ b/files/en-us/web/api/cookiestoremanager/subscribe/index.md @@ -3,12 +3,10 @@ title: "CookieStoreManager: subscribe() method" short-title: subscribe() slug: Web/API/CookieStoreManager/subscribe page-type: web-api-instance-method -status: - - experimental browser-compat: api.CookieStoreManager.subscribe --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}} The **`subscribe()`** method of the {{domxref("CookieStoreManager")}} interface subscribes a {{domxref("ServiceWorkerRegistration")}} to cookie change events. diff --git a/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md b/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md index c60932b0f18bafb..1d5b94f222f8009 100644 --- a/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md +++ b/files/en-us/web/api/cookiestoremanager/unsubscribe/index.md @@ -3,12 +3,10 @@ title: "CookieStoreManager: unsubscribe() method" short-title: unsubscribe() slug: Web/API/CookieStoreManager/unsubscribe page-type: web-api-instance-method -status: - - experimental browser-compat: api.CookieStoreManager.unsubscribe --- -{{securecontext_header}}{{APIRef("Cookie Store API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Cookie Store API")}} The **`unsubscribe()`** method of the {{domxref("CookieStoreManager")}} interface stops the {{domxref("ServiceWorkerRegistration")}} from receiving previously subscribed events. diff --git a/files/en-us/web/api/credential/id/index.md b/files/en-us/web/api/credential/id/index.md index 7e154cc2b31ee8b..044369e59a3d2b6 100644 --- a/files/en-us/web/api/credential/id/index.md +++ b/files/en-us/web/api/credential/id/index.md @@ -6,12 +6,9 @@ page-type: web-api-instance-property browser-compat: api.Credential.id --- -{{APIRef("Credential Management API")}} +{{APIRef("Credential Management API")}}{{SecureContext_Header}} -The **`id`** property of the -{{domxref("Credential")}} interface returns a string containing the -credential's identifier. This might be any one of a GUID, username, or email -address. +The **`id`** read-only property of the {{domxref("Credential")}} interface returns a string containing the credential's identifier. This might be a GUID, username, or email address, or some other value, depending on the type of credential. ## Value diff --git a/files/en-us/web/api/credential/index.md b/files/en-us/web/api/credential/index.md index 59f009df869b0c8..4bf0db98b506388 100644 --- a/files/en-us/web/api/credential/index.md +++ b/files/en-us/web/api/credential/index.md @@ -9,23 +9,20 @@ browser-compat: api.Credential The **`Credential`** interface of the [Credential Management API](/en-US/docs/Web/API/Credential_Management_API) provides information about an entity (usually a user) normally as a prerequisite to a trust decision. -`Credential` objects may be of four different types: +`Credential` objects may be of the following types: - {{domxref("FederatedCredential")}} - {{domxref("IdentityCredential")}} - {{domxref("PasswordCredential")}} - {{domxref("PublicKeyCredential")}} +- {{domxref("OTPCredential")}} ## Instance properties - {{domxref("Credential.id")}} {{ReadOnlyInline}} - : Returns a string containing the credential's identifier. This might be any one of a GUID, username, or email address. - {{domxref("Credential.type")}} {{ReadOnlyInline}} - - : Returns a string containing the credential's type. Valid values are `password`, `federated` and `public-key`. (For {{domxref("PasswordCredential")}}, {{domxref("FederatedCredential")}} and {{domxref("PublicKeyCredential")}}) - -### Event handlers - -None. + - : Returns a string containing the credential's type. Valid values are `password`, `federated`, `public-key`, `identity` and `otp`. (For {{domxref("PasswordCredential")}}, {{domxref("FederatedCredential")}}, {{domxref("PublicKeyCredential")}}, {{domxref("IdentityCredential")}} and {{domxref("OTPCredential")}}) ## Instance methods @@ -34,7 +31,7 @@ None. ## Examples ```js -let pwdCredential = new PasswordCredential({ +const pwdCredential = new PasswordCredential({ id: "example-username", // Username/ID name: "Carina Anand", // Display name password: "correct horse battery staple", // Password diff --git a/files/en-us/web/api/credential/type/index.md b/files/en-us/web/api/credential/type/index.md index 59bd38238382303..2a11b3b2bbd7015 100644 --- a/files/en-us/web/api/credential/type/index.md +++ b/files/en-us/web/api/credential/type/index.md @@ -6,23 +6,14 @@ page-type: web-api-instance-property browser-compat: api.Credential.type --- -{{APIRef("Credential Management API")}} +{{APIRef("Credential Management API")}}{{SecureContext_Header}} -The **`type`** property of the -{{domxref("Credential")}} interface returns a string containing the -credential's type. Valid values are `password`, `federated` and -`public-key`. +The **`type`** read-only property of the {{domxref("Credential")}} interface returns a string containing the credential's type. Valid values are `password`, `federated`, `public-key`, `identity` and `otp`. ## Value A string contains a credential's given name. -## Examples - -```js -// TBD -``` - ## Specifications {{Specifications}} diff --git a/files/en-us/web/api/credential_management_api/index.md b/files/en-us/web/api/credential_management_api/index.md index 0705b9dae2b4575..89e784d83674a84 100644 --- a/files/en-us/web/api/credential_management_api/index.md +++ b/files/en-us/web/api/credential_management_api/index.md @@ -2,14 +2,19 @@ title: Credential Management API slug: Web/API/Credential_Management_API page-type: web-api-overview -browser-compat: api.Credential +browser-compat: + - api.Credential + - api.CredentialsContainer + - api.FederatedCredential + - api.PasswordCredential +spec-urls: https://w3c.github.io/webappsec-credential-management/ --- -{{DefaultAPISidebar("Credential Management API")}} +{{DefaultAPISidebar("Credential Management API")}}{{securecontext_header}} The Credential Management API lets a website store and retrieve password, public key, and federated credentials. These capabilities allow users to sign in without typing passwords, see the federated account they used to sign in to a site, and resume a session without the explicit sign-in flow of an expired session. -## Credential management concepts and usage +## Concepts and usage This API lets websites interact with a user agent's password system directly so that websites can deal in a uniform way with site credentials and user agents can provide better assistance with the management of their credentials. For example, user agents have a particularly hard time dealing with federated identity providers or esoteric sign-in mechanisms. @@ -31,8 +36,11 @@ Later versions of the spec allow credentials to be retrieved from a different su - : Provides information about credentials from a federated identity provider, which is an entity that a website trusts to correctly authenticate a user, and which provides an API for that purpose. [OpenID Connect](https://openid.net/developers/specs/) is an example of such a framework. - {{domxref("PasswordCredential")}} - : Provides information about a username/password pair. -- {{domxref("PublicKeyCredential")}} - - : Provides a credential for logging in using a more secure system based on asymmetric cryptography instead of a password. + +### Extensions to other interfaces + +- {{domxref("Navigator.credentials")}} {{ReadOnlyInline}} + - : Returns the {{domxref("CredentialsContainer")}} interface which exposes methods to request credentials and notify the user agent when interesting events occur such as successful sign in or sign out. ## Specifications @@ -41,3 +49,9 @@ Later versions of the spec allow credentials to be retrieved from a different su ## Browser compatibility {{Compat}} + +## See also + +- {{domxref("Web Authentication API", "", "", "nocode")}} +- {{domxref("WebOTP API", "", "", "nocode")}} +- {{domxref("FedCM API", "Federated Credential Management (FedCM) API", "", "nocode")}} diff --git a/files/en-us/web/api/credentialscontainer/create/index.md b/files/en-us/web/api/credentialscontainer/create/index.md index 8e0a24cace913f1..93c70a13560d6e3 100644 --- a/files/en-us/web/api/credentialscontainer/create/index.md +++ b/files/en-us/web/api/credentialscontainer/create/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.CredentialsContainer.create --- -{{APIRef("Credential Management API")}} +{{APIRef("Credential Management API")}}{{SecureContext_Header}} The **`create()`** method of the {{domxref("CredentialsContainer")}} interface returns a {{jsxref("Promise")}} that resolves with a new credential instance based on the provided options, the information from which can then be stored and later used to authenticate users via {{domxref("CredentialsContainer.get", "navigator.credentials.get()")}}. @@ -110,10 +110,12 @@ If a single credential cannot be successfully created, the Promise will resolve ```js navigator.credentials .create({ - id: "ergnjregoith5y9865jhokmfdskl;vmfdl;kfd...", - name: "fluffybunny", - origin: "example.com", - password: "fluffyhaxx0r", + password: { + id: "ergnjregoith5y9865jhokmfdskl;vmfdl;kfd...", + name: "fluffybunny", + origin: "example.com", + password: "fluffyhaxx0r", + }, }) .then((pwdCred) => { console.log(pwdCred.name); @@ -313,8 +315,11 @@ A {{jsxref("Promise")}} that resolves with an {{domxref("PublicKeyCredential")}} ### Exceptions -- `SecurityError` {{domxref("DOMException")}} - - : Usage was blocked by a {{HTTPHeader("Permissions-Policy/publickey-credentials-create","publickey-credentials-create")}} [Permissions Policy](/en-US/docs/Web/HTTP/Permissions_Policy). +- `NotAllowedError` {{domxref("DOMException")}} + - : Possible causes include: + - Usage was blocked by a {{HTTPHeader("Permissions-Policy/publickey-credentials-create","publickey-credentials-create")}} [Permissions Policy](/en-US/docs/Web/HTTP/Permissions_Policy). + - The function is called cross-origin but the iframe's [`allow`](/en-US/docs/Web/HTML/Element/iframe#allow) attribute does not set an appropriate {{HTTPHeader("Permissions-Policy/publickey-credentials-create","publickey-credentials-create")}} policy. + - The function is called cross-origin and the ` +``` + +```js +const el = document.getElementById("el"); +console.log(el.allowFullscreen); // Output: true +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- [Fullscreen API](/en-US/docs/Web/API/Fullscreen_API) +- {{domxref("Element.requestFullscreen()")}} +- [Permissions Policy](/en-US/docs/Web/HTTP/Permissions_Policy) +- {{httpheader("Permissions-Policy/fullscreen", "fullscreen")}} Permissions Policy directive diff --git a/files/en-us/web/api/htmliframeelement/height/index.md b/files/en-us/web/api/htmliframeelement/height/index.md new file mode 100644 index 000000000000000..4806a7fc5413286 --- /dev/null +++ b/files/en-us/web/api/htmliframeelement/height/index.md @@ -0,0 +1,43 @@ +--- +title: "HTMLIFrameElement: height property" +short-title: height +slug: Web/API/HTMLIFrameElement/height +page-type: web-api-instance-property +browser-compat: api.HTMLIFrameElement.height +--- + +{{APIRef("HTML DOM")}} + +The **`height`** property of the {{domxref("HTMLIFrameElement")}} interface returns a string that reflects the `height` attribute of the {{HTMLElement("iframe")}} element, indicating the height of the frame in CSS pixels. + +## Value + +A string indicating the height of the frame in CSS pixels. + +## Examples + +```html + +``` + +```js +const el = document.getElementById("el"); +console.log(el.height); // Output: '600' +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("HTMLCanvasElement.height")}} +- {{domxref("HTMLEmbedElement.height")}} +- {{domxref("HTMLImageElement.height")}} +- {{domxref("HTMLObjectElement.height")}} +- {{domxref("HTMLSourceElement.height")}} +- {{domxref("HTMLVideoElement.height")}} diff --git a/files/en-us/web/api/htmliframeelement/index.md b/files/en-us/web/api/htmliframeelement/index.md index c77f6771ab6de37..131dd2504d91f88 100644 --- a/files/en-us/web/api/htmliframeelement/index.md +++ b/files/en-us/web/api/htmliframeelement/index.md @@ -19,7 +19,7 @@ _Inherits properties from its parent, {{domxref("HTMLElement")}}_. - : A string that specifies the alignment of the frame with respect to the surrounding context. - {{domxref("HTMLIFrameElement.allow")}} - : A list of origins the frame is allowed to display content from. This attribute also accepts the values `self` and `src` which represent the origin in the iframe's src attribute. The default value is `src`. -- {{domxref("HTMLIFrameElement.allowfullscreen")}} {{Experimental_Inline}} +- {{domxref("HTMLIFrameElement.allowFullscreen")}} - : A boolean value indicating whether the inline frame is willing to be placed into full screen mode. See [Using fullscreen mode](/en-US/docs/Web/API/Fullscreen_API) for details. - {{domxref("HTMLIFrameElement.allowPaymentRequest")}} {{Deprecated_Inline}} {{Non-standard_Inline}} - : A boolean value indicating whether the [Payment Request API](/en-US/docs/Web/API/Payment_Request_API) may be invoked inside a cross-origin iframe. @@ -35,6 +35,8 @@ _Inherits properties from its parent, {{domxref("HTMLElement")}}_. - {{domxref("HTMLIFrameElement.csp")}} {{Experimental_Inline}} - : Specifies the Content Security Policy that an embedded document must agree to enforce upon itself. +- {{domxref("HTMLIFrameElement.featurePolicy")}} {{ReadOnlyInline}} {{Experimental_Inline}} + - : Returns the {{domxref("FeaturePolicy")}} interface which provides a simple API for introspecting the [Permissions Policies](/en-US/docs/Web/HTTP/Permissions_Policy) applied to a specific document. - {{domxref("HTMLIFrameElement.frameBorder")}} {{Deprecated_Inline}} - : A string that indicates whether to create borders between frames. - {{domxref("HTMLIFrameElement.height")}} @@ -50,8 +52,6 @@ _Inherits properties from its parent, {{domxref("HTMLElement")}}_. - : A string being the width of the frame margin. - {{domxref("HTMLIFrameElement.name")}} - : A string that reflects the [`name`](/en-US/docs/Web/HTML/Element/iframe#name) HTML attribute, containing a name by which to refer to the frame. -- {{domxref("HTMLIFrameElement.featurePolicy")}} {{ReadOnlyInline}} {{Experimental_Inline}} - - : Returns the {{domxref("FeaturePolicy")}} interface which provides a simple API for introspecting the [Permissions Policies](/en-US/docs/Web/HTTP/Permissions_Policy) applied to a specific document. - {{domxref("HTMLIFrameElement.referrerPolicy")}} - : A string that reflects the [`referrerPolicy`](/en-US/docs/Web/HTML/Element/iframe#referrerpolicy) HTML attribute indicating which referrer to use when fetching the linked resource. - {{domxref("HTMLIFrameElement.sandbox")}} diff --git a/files/en-us/web/api/htmliframeelement/name/index.md b/files/en-us/web/api/htmliframeelement/name/index.md new file mode 100644 index 000000000000000..a5a43875ba65d16 --- /dev/null +++ b/files/en-us/web/api/htmliframeelement/name/index.md @@ -0,0 +1,34 @@ +--- +title: "HTMLIFrameElement: name property" +short-title: name +slug: Web/API/HTMLIFrameElement/name +page-type: web-api-instance-property +browser-compat: api.HTMLIFrameElement.name +--- + +{{APIRef("HTML DOM")}} + +The **`name`** property of the {{domxref("HTMLIFrameElement")}} interface is a string value that reflects the `name` attribute of the {{HTMLElement("iframe")}} element, indicating the specific name of the ` +``` + +```js +const el = document.getElementById("el"); +console.log(el.name); // Output: "example" +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/htmliframeelement/width/index.md b/files/en-us/web/api/htmliframeelement/width/index.md new file mode 100644 index 000000000000000..e839a434b4f4c58 --- /dev/null +++ b/files/en-us/web/api/htmliframeelement/width/index.md @@ -0,0 +1,43 @@ +--- +title: "HTMLIFrameElement: width property" +short-title: width +slug: Web/API/HTMLIFrameElement/width +page-type: web-api-instance-property +browser-compat: api.HTMLIFrameElement.width +--- + +{{APIRef("HTML DOM")}} + +The **`width`** property of the {{domxref("HTMLIFrameElement")}} interface returns a string that reflects the `width` attribute of the {{HTMLElement("iframe")}} element, indicating the width of the frame in CSS pixels. + +## Value + +A string indicating the width of the frame in CSS pixels. + +## Examples + +```html + +``` + +```js +const el = document.getElementById("el"); +console.log(el.width); // Output: '800' +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("HTMLCanvasElement.width")}} +- {{domxref("HTMLEmbedElement.width")}} +- {{domxref("HTMLImageElement.width")}} +- {{domxref("HTMLObjectElement.width")}} +- {{domxref("HTMLSourceElement.width")}} +- {{domxref("HTMLVideoElement.width")}} diff --git a/files/en-us/web/api/htmlimageelement/alt/index.md b/files/en-us/web/api/htmlimageelement/alt/index.md index d6ad632295906fc..60b75b4a91adb75 100644 --- a/files/en-us/web/api/htmlimageelement/alt/index.md +++ b/files/en-us/web/api/htmlimageelement/alt/index.md @@ -91,7 +91,7 @@ p { } .left-margin { - background-color: rgb(241, 240, 237); + background-color: rgb(241 240 237); width: 9em; height: 100%; float: left; @@ -107,7 +107,7 @@ p { } .contents { - background-color: rgb(241, 240, 235); + background-color: rgb(241 240 235); height: 100%; margin-left: 2em; padding-top: 1em; diff --git a/files/en-us/web/api/htmlimageelement/crossorigin/index.md b/files/en-us/web/api/htmlimageelement/crossorigin/index.md index 9d13c24e4f889ae..59c37f23fc83988 100644 --- a/files/en-us/web/api/htmlimageelement/crossorigin/index.md +++ b/files/en-us/web/api/htmlimageelement/crossorigin/index.md @@ -103,7 +103,7 @@ img { } output { - background: rgba(100, 100, 100, 0.1); + background: rgb(100 100 100 / 100%); font-family: Courier, monospace; width: 95%; } @@ -120,3 +120,9 @@ output { ## Browser compatibility {{Compat}} + +## See also + +- {{domxref("HTMLLinkElement.crossOrigin")}} +- {{domxref("HTMLMediaElement.crossOrigin")}} +- {{domxref("HTMLScriptElement.crossOrigin")}} diff --git a/files/en-us/web/api/htmlimageelement/height/index.md b/files/en-us/web/api/htmlimageelement/height/index.md index 9b479bc9f6c4f1a..ad24155653463e5 100644 --- a/files/en-us/web/api/htmlimageelement/height/index.md +++ b/files/en-us/web/api/htmlimageelement/height/index.md @@ -79,3 +79,12 @@ This example may be easier to try out {{LiveSampleLink('Examples', 'in its own w ## Browser compatibility {{Compat}} + +## See also + +- {{domxref("HTMLCanvasElement.height")}} +- {{domxref("HTMLEmbedElement.height")}} +- {{domxref("HTMLIFrameElement.height")}} +- {{domxref("HTMLObjectElement.height")}} +- {{domxref("HTMLSourceElement.height")}} +- {{domxref("HTMLVideoElement.height")}} diff --git a/files/en-us/web/api/htmlimageelement/sizes/index.md b/files/en-us/web/api/htmlimageelement/sizes/index.md index 33cc8cc09aa7c53..45212ef6ef54ecf 100644 --- a/files/en-us/web/api/htmlimageelement/sizes/index.md +++ b/files/en-us/web/api/htmlimageelement/sizes/index.md @@ -10,7 +10,7 @@ browser-compat: api.HTMLImageElement.sizes The {{domxref("HTMLImageElement")}} property **`sizes`** allows you to specify the layout width of the -image for each of a list of media conditions. This provides the ability to +[image](/en-US/docs/Web/HTML/Element/img) for each of a list of media conditions. This provides the ability to automatically select among different images—even images of different orientations or aspect ratios—as the document state changes to match different media conditions. @@ -31,13 +31,13 @@ evaluates to `true`. Each source size descriptor consists of a media condition as defined by the media queries standard. Because a source size descriptor is used to specify the width to use for the image during layout of the page, the media condition is typically (but not -necessarily) based entirely on width information. See +necessarily) based entirely on [width](/en-US/docs/Web/CSS/@media/width) information. See [Using media queries, Syntax](/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries#syntax) for details on how to construct a media condition. ### Source size values -The source size value is a [CSS length](/en-US/docs/Web/CSS/length). It may +The source size value is a CSS {{cssxref("length")}}. It may be specified using font-relative units (such as `em` or `ex`), absolute units (such as `px` or `cm`), or the `vw` unit, which lets you specify the width as a percentage of the viewport width @@ -58,8 +58,8 @@ versions of the image are also available, with their widths specified. The brows all of this information and selects an image and width that best meets the specified values. -How exactly the images are used may depend upon the browser and what the pixel density -of the user's display is. +How exactly the images are used may depend upon the browser and the pixel density +of the user's display. Buttons at the bottom of the example let you actually modify the `sizes` property slightly, switching the largest of the three widths for the image between 40em @@ -127,8 +127,8 @@ article img { The JavaScript code handles the two buttons that let you toggle the third width option between 40em and 50em; this is done by handling the {{domxref("Element.click_event", - "click")}} event, using the JavaScript string object method {{jsxref("String.replace", - "replace()")}} to replace the relevant portion of the `sizes` string. + "click")}} event, using the JavaScript string object {{jsxref("String.replace", + "replace()")}} method to replace the relevant portion of the `sizes` string. ```js const image = document.querySelector("article img"); @@ -166,3 +166,4 @@ The page is best {{LiveSampleLink('Selecting an image to fit window width', 'vie - [Using media queries](/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries) - [Images in HTML](/en-US/docs/Learn/HTML/Multimedia_and_embedding/Images_in_HTML) - [Responsive images](/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images) +- [Using the `srcset` and `sizes` attributes](/en-US/docs/Web/HTML/Element/img#using_the_srcset_and_sizes_attributes) diff --git a/files/en-us/web/api/htmlimageelement/srcset/index.md b/files/en-us/web/api/htmlimageelement/srcset/index.md index ed9ff55e08ae798..ce9ff13ae5d3e5a 100644 --- a/files/en-us/web/api/htmlimageelement/srcset/index.md +++ b/files/en-us/web/api/htmlimageelement/srcset/index.md @@ -113,7 +113,7 @@ the wrap must occur. ```css .box { width: 200px; - border: 2px solid rgb(150, 150, 150); + border: 2px solid rgb(150 150 150); padding: 0.5em; word-break: break-all; } diff --git a/files/en-us/web/api/htmlimageelement/width/index.md b/files/en-us/web/api/htmlimageelement/width/index.md index c27d2ce70114985..5280d19951df7b1 100644 --- a/files/en-us/web/api/htmlimageelement/width/index.md +++ b/files/en-us/web/api/htmlimageelement/width/index.md @@ -82,3 +82,12 @@ This example may be easier to try out {{LiveSampleLink('Examples', 'in its own w ## Browser compatibility {{Compat}} + +## See also + +- {{domxref("HTMLCanvasElement.width")}} +- {{domxref("HTMLEmbedElement.width")}} +- {{domxref("HTMLIFrameElement.width")}} +- {{domxref("HTMLObjectElement.width")}} +- {{domxref("HTMLSourceElement.width")}} +- {{domxref("HTMLVideoElement.width")}} diff --git a/files/en-us/web/api/htmlimageelement/x/index.md b/files/en-us/web/api/htmlimageelement/x/index.md index 1e03c58c6de41e4..a795435efccf054 100644 --- a/files/en-us/web/api/htmlimageelement/x/index.md +++ b/files/en-us/web/api/htmlimageelement/x/index.md @@ -117,13 +117,13 @@ The CSS defining the appearance of the table: table { border-collapse: collapse; - border: 2px solid rgb(100, 100, 100); + border: 2px solid rgb(100 100 100); font-family: sans-serif; } td, th { - border: 1px solid rgb(100, 100, 100); + border: 1px solid rgb(100 100 100); padding: 10px 14px; } diff --git a/files/en-us/web/api/htmlinputelement/index.md b/files/en-us/web/api/htmlinputelement/index.md index e3a9ef114097dc9..cdbec43f7188db8 100644 --- a/files/en-us/web/api/htmlinputelement/index.md +++ b/files/en-us/web/api/htmlinputelement/index.md @@ -13,43 +13,41 @@ The **`HTMLInputElement`** interface provides special properties and methods for ## Instance properties +_Also inherits properties from its parent interface, {{domxref("HTMLElement")}}._ + Some properties only apply to input element types that support the corresponding attributes. - {{domxref("HTMLInputElement.align", "align")}} {{Deprecated_Inline}} - - : `string`: **Represents** the alignment of the element. _Use CSS instead._ - -- {{domxref("HTMLInputElement.autocapitalize", "autocapitalize")}} {{Experimental_Inline}} - - - : `string`: **Defines** the capitalization behavior for user input. Valid values are `none`, `off`, `characters`, `words` or `sentences`. + - : A string that represents the alignment of the element. _Use CSS instead._ - {{domxref("HTMLInputElement.defaultValue", "defaultValue")}} - - : `string`: **Returns / Sets** the default value as originally specified in the HTML that created this object. + - : A string that represents the default value as originally specified in the HTML that created this object. - {{domxref("HTMLInputElement.dirName", "dirName")}} - - : `string`: **Returns / Sets** the directionality of the element. + - : A string that represents the directionality of the element. -- {{domxref("HTMLInputElement.inputmode", "inputmode")}} +- {{domxref("HTMLInputElement.incremental", "incremental")}} {{Non-standard_Inline}} - - : Provides a hint to browsers as to the type of virtual keyboard configuration to use when editing this element or its contents. + - : A boolean that represents the search event fire mode, if `true`, fires on every keypress, or on clicking the cancel button; otherwise fires when pressing Enter. - {{domxref("HTMLInputElement.labels", "labels")}} {{ReadOnlyInline}} - - : {{domxref("NodeList")}} array: **Returns** a list of {{ HTMLElement("label") }} elements that are labels for this element. + - : Returns a list of {{ HTMLElement("label") }} elements that are labels for this element. - {{domxref("HTMLInputElement.list", "list")}} {{ReadOnlyInline}} - - : {{domxref("HTMLElement")}}: **Returns** the element pointed to by the [`list`](/en-US/docs/Web/HTML/Element/input#list) attribute. The property may be `null` if no HTML element is found in the same tree. + - : Returns the element pointed to by the [`list`](/en-US/docs/Web/HTML/Element/input#list) attribute. The property may be `null` if no HTML element is found in the same tree. - {{domxref("HTMLInputElement.multiple", "multiple")}} - - : `boolean`: **Returns / Sets** the element's [`multiple`](/en-US/docs/Web/HTML/Element/input#multiple) attribute, indicating whether more than one value is possible (e.g., multiple files). + - : A boolean that represents the element's [`multiple`](/en-US/docs/Web/HTML/Element/input#multiple) attribute, indicating whether more than one value is possible (e.g., multiple files). - {{domxref("HTMLInputElement.name", "name")}} - - : `string`: **Returns / Sets** the element's [`name`](/en-US/docs/Web/HTML/Element/input#name) attribute, containing a name that identifies the element when submitting the form. + - : A string that represents the element's [`name`](/en-US/docs/Web/HTML/Element/input#name) attribute, containing a name that identifies the element when submitting the form. - {{domxref("HTMLInputElement.popoverTargetAction", "popoverTargetAction")}} @@ -61,244 +59,224 @@ Some properties only apply to input element types that support the corresponding - {{domxref("HTMLInputElement.step", "step")}} - - : `string`: **Returns / Sets** the element's [`step`](/en-US/docs/Web/HTML/Element/input#step) attribute, which works with [`min`](/en-US/docs/Web/HTML/Element/input#min) and [`max`](/en-US/docs/Web/HTML/Element/input#max) to limit the increments at which a numeric or date-time value can be set. It can be the string `any` or a positive floating point number. If this is not set to `any`, the control accepts only values at multiples of the step value greater than the minimum. + - : A string that represents the element's [`step`](/en-US/docs/Web/HTML/Element/input#step) attribute, which works with [`min`](/en-US/docs/Web/HTML/Element/input#min) and [`max`](/en-US/docs/Web/HTML/Element/input#max) to limit the increments at which a numeric or date-time value can be set. It can be the string `any` or a positive floating point number. If this is not set to `any`, the control accepts only values at multiples of the step value greater than the minimum. - {{domxref("HTMLInputElement.type", "type")}} - - : `string`: **Returns / Sets** the element's [`type`](/en-US/docs/Web/HTML/Element/input#type) attribute, indicating the type of control to display. For possible values, see the documentation for the [`type`](/en-US/docs/Web/HTML/Element/input#type) attribute. + - : A string that represents the element's [`type`](/en-US/docs/Web/HTML/Element/input#type) attribute, indicating the type of control to display. For possible values, see the documentation for the [`type`](/en-US/docs/Web/HTML/Element/input#type) attribute. - {{domxref("HTMLInputElement.useMap", "useMap")}} {{Deprecated_Inline}} - - : `string`: **Represents** a client-side image map. + - : A string that represents a client-side image map. - {{domxref("HTMLInputElement.value", "value")}} - - : `string`: **Returns / Sets** the current value of the control. If the user enters a value different from the value expected, this may return an empty string. + - : A string that represents the current value of the control. If the user enters a value different from the value expected, this may return an empty string. - {{domxref("HTMLInputElement.valueAsDate", "valueAsDate")}} - - : {{jsxref("Date")}}: **Returns / Sets** the value of the element, interpreted as a date, or `null` if conversion is not possible. + - : A {{jsxref("Date")}} that represents the value of the element, interpreted as a date, or `null` if conversion is not possible. - {{domxref("HTMLInputElement.valueAsNumber", "valueAsNumber")}} - - : `double`: **Returns** the value of the element, interpreted as one of the following, in order: A time value, a number or `NaN` if conversion is impossible + - : A number that represents the value of the element, interpreted as one of the following, in order: A time value, a number, or `NaN` if conversion is impossible. ### Instance properties related to the parent form - {{domxref("HTMLInputElement.form", "form")}} {{ReadOnlyInline}} - - : {{domxref("HTMLFormElement")}}: **Returns** a reference to the parent {{HtmlElement("form")}} element. + - : Returns a reference to the parent {{HtmlElement("form")}} element. - {{domxref("HTMLInputElement.formAction", "formAction")}} - - : `string`: **Returns / Sets** the element's [`formaction`](/en-US/docs/Web/HTML/Element/input#formaction) attribute, containing the URL of a program that processes information submitted by the element. This overrides the [`action`](/en-US/docs/Web/HTML/Element/form#action) attribute of the parent form. + - : A string that represents the element's [`formaction`](/en-US/docs/Web/HTML/Element/input#formaction) attribute, containing the URL of a program that processes information submitted by the element. This overrides the [`action`](/en-US/docs/Web/HTML/Element/form#action) attribute of the parent form. - {{domxref("HTMLInputElement.formEnctype", "formEnctype")}} - - : `string`: **Returns / Sets** the element's [`formenctype`](/en-US/docs/Web/HTML/Element/input#formenctype) attribute, containing the type of content that is used to submit the form to the server. This overrides the [`enctype`](/en-US/docs/Web/HTML/Element/form#enctype) attribute of the parent form. + - : A string that represents the element's [`formenctype`](/en-US/docs/Web/HTML/Element/input#formenctype) attribute, containing the type of content that is used to submit the form to the server. This overrides the [`enctype`](/en-US/docs/Web/HTML/Element/form#enctype) attribute of the parent form. - {{domxref("HTMLInputElement.formMethod", "formMethod")}} - - : `string`: **Returns / Sets** the element's [`formmethod`](/en-US/docs/Web/HTML/Element/input#formmethod) attribute, containing the HTTP method that the browser uses to submit the form. This overrides the [`method`](/en-US/docs/Web/HTML/Element/form#method) attribute of the parent form. + - : A string that represents the element's [`formmethod`](/en-US/docs/Web/HTML/Element/input#formmethod) attribute, containing the HTTP method that the browser uses to submit the form. This overrides the [`method`](/en-US/docs/Web/HTML/Element/form#method) attribute of the parent form. - {{domxref("HTMLInputElement.formNoValidate", "formNoValidate")}} - - : `boolean`: **Returns / Sets** the element's [`formnovalidate`](/en-US/docs/Web/HTML/Element/input#formnovalidate) attribute, indicating that the form is not to be validated when it is submitted. This overrides the [`novalidate`](/en-US/docs/Web/HTML/Element/form#novalidate) attribute of the parent form. + - : A boolean that represents the element's [`formnovalidate`](/en-US/docs/Web/HTML/Element/input#formnovalidate) attribute, indicating that the form is not to be validated when it is submitted. This overrides the [`novalidate`](/en-US/docs/Web/HTML/Element/form#novalidate) attribute of the parent form. - {{domxref("HTMLInputElement.formTarget", "formTarget")}} - - : `string`: **Returns / Sets** the element's [`formtarget`](/en-US/docs/Web/HTML/Element/input#formtarget) attribute, containing a name or keyword indicating where to display the response that is received after submitting the form. This overrides the [`target`](/en-US/docs/Web/HTML/Element/form#target) attribute of the parent form. + - : A string that represents the element's [`formtarget`](/en-US/docs/Web/HTML/Element/input#formtarget) attribute, containing a name or keyword indicating where to display the response that is received after submitting the form. This overrides the [`target`](/en-US/docs/Web/HTML/Element/form#target) attribute of the parent form. ### Instance properties that apply to any type of input element that is not hidden -- {{domxref("HTMLInputElement.autofocus", "autofocus")}} - - - : `boolean`: **Returns / Sets** the element's [`autofocus`](/en-US/docs/Web/HTML/Element/input#autofocus) attribute, which specifies that a form control should have input focus when the page loads, unless the user overrides it, for example by typing in a different control. Only one form element in a document can have the [`autofocus`](/en-US/docs/Web/HTML/Element/input#autofocus) attribute. - - {{domxref("HTMLInputElement.disabled", "disabled")}} - - : `boolean`: **Returns / Sets** the element's [`disabled`](/en-US/docs/Web/HTML/Element/input#disabled) attribute, indicating that the control is not available for interaction. The input values will not be submitted with the form. See also [`readonly`](/en-US/docs/Web/HTML/Element/input#readonly). + - : A boolean that represents the element's [`disabled`](/en-US/docs/Web/HTML/Element/input#disabled) attribute, indicating that the control is not available for interaction. The input values will not be submitted with the form. See also [`readonly`](/en-US/docs/Web/HTML/Element/input#readonly). - {{domxref("HTMLInputElement.required", "required")}} - - : `boolean`: **Returns / Sets** the element's [`required`](/en-US/docs/Web/HTML/Element/input#required) attribute, indicating that the user must fill in a value before submitting a form. + - : A boolean that represents the element's [`required`](/en-US/docs/Web/HTML/Element/input#required) attribute, indicating that the user must fill in a value before submitting a form. - {{domxref("HTMLInputElement.validationMessage", "validationMessage")}} {{ReadOnlyInline}} - - : `string`: **Returns** a localized message that describes the validation constraints that the control does not satisfy (if any). This is the empty string if the control is not a candidate for constraint validation ([`willValidate`](/en-US/docs/Web/API/HTMLObjectElement/willValidate) is `false`), or it satisfies its constraints. This value can be set by the {{domxref("HTMLInputElement.setCustomValidity()", "setCustomValidity()")}} method. + - : Returns a localized message that describes the validation constraints that the control does not satisfy (if any). This is the empty string if the control is not a candidate for constraint validation ([`willValidate`](/en-US/docs/Web/API/HTMLObjectElement/willValidate) is `false`), or it satisfies its constraints. This value can be set by the {{domxref("HTMLInputElement.setCustomValidity()", "setCustomValidity()")}} method. - {{domxref("HTMLInputElement.validity", "validity")}} {{ReadOnlyInline}} - - : {{domxref("ValidityState")}}: **Returns** the element's current validity state. + - : Returns the element's current validity state. - {{domxref("HTMLInputElement.willValidate", "willValidate")}} {{ReadOnlyInline}} - - : `boolean`: **Returns** whether the element is a candidate for constraint validation. It is `false` if any conditions bar it from constraint validation, including: its `type` is one of `hidden`, `reset` or `button`, it has a {{HTMLElement("datalist")}} ancestor or its `disabled` property is `true`. + - : Returns whether the element is a candidate for constraint validation. It is `false` if any conditions bar it from constraint validation, including: its `type` is one of `hidden`, `reset` or `button`, it has a {{HTMLElement("datalist")}} ancestor or its `disabled` property is `true`. ### Instance properties that apply only to elements of type checkbox or radio - {{domxref("HTMLInputElement.checked", "checked")}} - - : `boolean`: **Returns / Sets** the current state of the element. + - : A boolean that represents the current state of the element. - {{domxref("HTMLInputElement.defaultChecked", "defaultChecked")}} - - : `boolean`: **Returns / Sets** the default state of a radio button or checkbox as originally specified in HTML that created this object. + - : A boolean that represents the default state of a radio button or checkbox as originally specified in HTML that created this object. - {{domxref("HTMLInputElement.indeterminate", "indeterminate")}} - - : `boolean`: **Returns** whether the checkbox or radio button is in indeterminate state. For checkboxes, the effect is that the appearance of the checkbox is obscured/greyed in some way as to indicate its state is indeterminate (not checked but not unchecked). Does not affect the value of the `checked` attribute, and clicking the checkbox will set the value to false. + - : A boolean that represents whether the checkbox or radio button is in indeterminate state. For checkboxes, the effect is that the appearance of the checkbox is obscured/greyed in some way as to indicate its state is indeterminate (not checked but not unchecked). Does not affect the value of the `checked` attribute, and clicking the checkbox will set the value to false. ### Instance properties that apply only to elements of type image - {{domxref("HTMLInputElement.alt", "alt")}} - - : `string`: **Returns / Sets** the element's [`alt`](/en-US/docs/Web/HTML/Element/input#alt) attribute, containing alternative text to use. + - : A string that represents the element's [`alt`](/en-US/docs/Web/HTML/Element/input#alt) attribute, containing alternative text to use. - {{domxref("HTMLInputElement.height", "height")}} - - : `string`: **Returns / Sets** the element's [`height`](/en-US/docs/Web/HTML/Element/input#height) attribute, which defines the height of the image displayed for the button. + - : A string that represents the element's [`height`](/en-US/docs/Web/HTML/Element/input#height) attribute, which defines the height of the image displayed for the button. - {{domxref("HTMLInputElement.src", "src")}} - - : `string`: **Returns / Sets** the element's [`src`](/en-US/docs/Web/HTML/Element/input#src) attribute, which specifies a URI for the location of an image to display on the graphical submit button. + - : A string that represents the element's [`src`](/en-US/docs/Web/HTML/Element/input#src) attribute, which specifies a URI for the location of an image to display on the graphical submit button. - {{domxref("HTMLInputElement.width", "width")}} - - : `string`: **Returns / Sets** the element's [`width`](/en-US/docs/Web/HTML/Element/input#width) attribute, which defines the width of the image displayed for the button. + - : A string that represents the element's [`width`](/en-US/docs/Web/HTML/Element/input#width) attribute, which defines the width of the image displayed for the button. ### Instance properties that apply only to elements of type file - {{domxref("HTMLInputElement.accept", "accept")}} - - : `string`: **Returns / Sets** the element's [`accept`](/en-US/docs/Web/HTML/Element/input#accept) attribute, containing comma-separated list of file types that can be selected. - -- {{domxref("HTMLInputElement.allowdirs", "allowdirs")}} {{Non-standard_Inline}} - - - : `boolean`: Part of the non-standard Directory Upload API. Indicates whether or not to allow directories and files both to be selected in the file list. Implemented only in Firefox and is hidden behind a preference. + - : A string that represents the element's [`accept`](/en-US/docs/Web/HTML/Element/input#accept) attribute, containing comma-separated list of file types that can be selected. - {{domxref("HTMLInputElement.files", "files")}} - - : {{domxref("FileList")}}: **Returns / Sets** a list of {{domxref("File")}} objects representing the files selected for upload. + - : A {{domxref("FileList")}} that represents the files selected for upload. - {{domxref("HTMLInputElement.webkitdirectory", "webkitdirectory")}} - - : `boolean`: **Returns** the [`webkitdirectory`](/en-US/docs/Web/HTML/Element/input#webkitdirectory) attribute. If `true`, the file-system-picker interface only accepts directories instead of files. + - : A boolean that represents the [`webkitdirectory`](/en-US/docs/Web/HTML/Element/input#webkitdirectory) attribute. If `true`, the file-system-picker interface only accepts directories instead of files. -- {{domxref("HTMLInputElement.webkitEntries", "webkitEntries")}} - - : {{domxref("FileSystemEntry")}} array: **Describes** the currently selected files or directories. +- {{domxref("HTMLInputElement.webkitEntries", "webkitEntries")}} {{ReadOnlyInline}} + - : Describes the currently selected files or directories. ### Instance properties that apply only to visible elements containing text or numbers - {{domxref("HTMLInputElement.autocomplete", "autocomplete")}} - - : `string`: **Returns / Sets** the element's [`autocomplete`](/en-US/docs/Web/HTML/Element/input#autocomplete) attribute, indicating whether the value of the control can be automatically completed by the browser. + - : A string that represents the element's [`autocomplete`](/en-US/docs/Web/HTML/Element/input#autocomplete) attribute, indicating whether the value of the control can be automatically completed by the browser. + +- {{domxref("HTMLInputElement.capture", "capture")}} + + - : A string that represents the element's [`capture`](/en-US/docs/Web/HTML/Element/input#capture) attribute, indicating the media capture input method in file upload controls. - {{domxref("HTMLInputElement.max", "max")}} - - : `string`: **Returns / Sets** the element's [`max`](/en-US/docs/Web/HTML/Element/input#max) attribute, containing the maximum (numeric or date-time) value for this item, which must not be less than its minimum ([`min`](/en-US/docs/Web/HTML/Element/input#min) attribute) value. + - : A string that represents the element's [`max`](/en-US/docs/Web/HTML/Element/input#max) attribute, containing the maximum (numeric or date-time) value for this item, which must not be less than its minimum ([`min`](/en-US/docs/Web/HTML/Element/input#min) attribute) value. - {{domxref("HTMLInputElement.maxLength", "maxLength")}} - - : `unsigned long`: **Returns / Sets** the element's [`maxlength`](/en-US/docs/Web/HTML/Element/input#maxlength) attribute, containing the maximum number of characters (in Unicode code points) that the value can have. + - : A number that represents the element's [`maxlength`](/en-US/docs/Web/HTML/Element/input#maxlength) attribute, containing the maximum number of characters (in Unicode code points) that the value can have. - {{domxref("HTMLInputElement.min", "min")}} - - : `string`: **Returns / Sets** the element's [`min`](/en-US/docs/Web/HTML/Element/input#min) attribute, containing the minimum (numeric or date-time) value for this item, which must not be greater than its maximum ([`max`](/en-US/docs/Web/HTML/Element/input#max) attribute) value. + - : A string that represents the element's [`min`](/en-US/docs/Web/HTML/Element/input#min) attribute, containing the minimum (numeric or date-time) value for this item, which must not be greater than its maximum ([`max`](/en-US/docs/Web/HTML/Element/input#max) attribute) value. - {{domxref("HTMLInputElement.minLength", "minLength")}} - - : `unsigned long`: **Returns / Sets** the element's [`minlength`](/en-US/docs/Web/HTML/Element/input#minlength) attribute, containing the minimum number of characters (in Unicode code points) that the value can have. + - : A number that represents the element's [`minlength`](/en-US/docs/Web/HTML/Element/input#minlength) attribute, containing the minimum number of characters (in Unicode code points) that the value can have. - {{domxref("HTMLInputElement.pattern", "pattern")}} - - : `string`: **Returns / Sets** the element's [`pattern`](/en-US/docs/Web/HTML/Element/input#pattern) attribute, containing a regular expression that the control's value is checked against. Use the [`title`](/en-US/docs/Web/HTML/Element/input#title) attribute to describe the pattern to help the user. This attribute only applies when the value of the [`type`](/en-US/docs/Web/HTML/Element/input#type) attribute is `text`, `search`, `tel`, `url` or `email`. + - : A string that represents the element's [`pattern`](/en-US/docs/Web/HTML/Element/input#pattern) attribute, containing a regular expression that the control's value is checked against. Use the [`title`](/en-US/docs/Web/HTML/Element/input#title) attribute to describe the pattern to help the user. This attribute only applies when the value of the [`type`](/en-US/docs/Web/HTML/Element/input#type) attribute is `text`, `search`, `tel`, `url` or `email`. - {{domxref("HTMLInputElement.placeholder", "placeholder")}} - - : `string`: **Returns / Sets** the element's [`placeholder`](/en-US/docs/Web/HTML/Element/input#placeholder) attribute, containing a hint to the user of what can be entered in the control. The placeholder text must not contain carriage returns or line-feeds. This attribute only applies when the value of the [`type`](/en-US/docs/Web/HTML/Element/input#type) attribute is `text`, `search`, `tel`, `url` or `email`. + - : A string that represents the element's [`placeholder`](/en-US/docs/Web/HTML/Element/input#placeholder) attribute, containing a hint to the user of what can be entered in the control. The placeholder text must not contain carriage returns or line-feeds. This attribute only applies when the value of the [`type`](/en-US/docs/Web/HTML/Element/input#type) attribute is `text`, `search`, `tel`, `url` or `email`. - {{domxref("HTMLInputElement.readOnly", "readOnly")}} - - : `boolean`: **Returns / Sets** the element's [`readonly`](/en-US/docs/Web/HTML/Element/input#readonly) attribute, indicating that the user cannot modify the value of the control. This is ignored if the [`type`](/en-US/docs/Web/HTML/Element/input#type) is `hidden`, `range`, `color`, `checkbox`, `radio`, `file`, or a button type. + - : A boolean that represents the element's [`readonly`](/en-US/docs/Web/HTML/Element/input#readonly) attribute, indicating that the user cannot modify the value of the control. This is ignored if the [`type`](/en-US/docs/Web/HTML/Element/input#type) is `hidden`, `range`, `color`, `checkbox`, `radio`, `file`, or a button type. -- {{domxref("HTMLInputElement.selectionEnd", "selectionEnd")}} +- {{domxref("HTMLInputElement.selectionDirection", "selectionDirection")}} - - : `unsigned long`: **Returns / Sets** the end index of the selected text. When there's no selection, this returns the offset of the character immediately following the current text input cursor position. + - : A string that represents the direction in which selection occurred. Possible values are: `forward` (the selection was performed in the start-to-end direction of the current locale), `backward` (the opposite direction) or `none` (the direction is unknown). -- {{domxref("HTMLInputElement.selectionStart", "selectionStart")}} +- {{domxref("HTMLInputElement.selectionEnd", "selectionEnd")}} - - : `unsigned long`: **Returns / Sets** the beginning index of the selected text. When nothing is selected, this returns the position of the text input cursor (caret) inside of the {{HTMLElement("input")}} element. + - : A number that represents the end index of the selected text. When there's no selection, this returns the offset of the character immediately following the current text input cursor position. -- {{domxref("HTMLInputElement.selectionDirection", "selectionDirection")}} +- {{domxref("HTMLInputElement.selectionStart", "selectionStart")}} - - : `string`: **Returns / Sets** the direction in which selection occurred. Possible values are: `forward` (the selection was performed in the start-to-end direction of the current locale), `backward` (the opposite direction) or `none` (the direction is unknown). + - : A number that represents the beginning index of the selected text. When nothing is selected, this returns the position of the text input cursor (caret) inside of the {{HTMLElement("input")}} element. - {{domxref("HTMLInputElement.size", "size")}} - - : `unsigned long`: **Returns / Sets** the element's [`size`](/en-US/docs/Web/HTML/Element/input#size) attribute, containing visual size of the control. This value is in pixels unless the value of [`type`](/en-US/docs/Web/HTML/Element/input#type) is `text` or `password`, in which case, it is an integer number of characters. Applies only when [`type`](/en-US/docs/Web/HTML/Element/input#type) is set to `text`, `search`, `tel`, `url`, `email`, or `password`. + - : A number that represents the element's [`size`](/en-US/docs/Web/HTML/Element/input#size) attribute, containing visual size of the control. This value is in pixels unless the value of [`type`](/en-US/docs/Web/HTML/Element/input#type) is `text` or `password`, in which case, it is an integer number of characters. Applies only when [`type`](/en-US/docs/Web/HTML/Element/input#type) is set to `text`, `search`, `tel`, `url`, `email`, or `password`. ## Instance methods -- {{domxref("HTMLElement/blur", "blur()")}} +_Also inherits methods from its parent interface, {{domxref("HTMLElement")}}._ - - : Removes focus from the input element; keystrokes will subsequently go nowhere. - -- {{domxref("HTMLElement.click()", "click()")}} +- {{domxref("HTMLInputElement.checkValidity()", "checkValidity()")}} - - : Simulates a click on the input element. + - : Returns a boolean value that is `false` if the element is a candidate for constraint validation, and it does not satisfy its constraints. In this case, it also fires an {{domxref("HTMLInputElement/invalid_event", "invalid")}} event at the element. It returns `true` if the element is not a candidate for constraint validation, or if it satisfies its constraints. -- {{domxref("HTMLElement/focus", "focus()")}} +- {{domxref("HTMLInputElement.reportValidity()", "reportValidity()")}} - - : Focuses on the input element; keystrokes will subsequently go to this element. + - : Runs the `checkValidity()` method, and if it returns false (for an invalid input or no pattern attribute provided), then it reports to the user that the input is invalid in the same manner as if you submitted a form. - {{domxref("HTMLInputElement.select()", "select()")}} - : Selects all the text in the input element, and focuses it so the user can subsequently replace all of its content. -- {{domxref("HTMLInputElement.setSelectionRange()", "setSelectionRange()")}} +- {{domxref("HTMLInputElement.setCustomValidity()", "setCustomValidity()")}} - - : Selects a range of text in the input element (but does not focus it). + - : Sets a custom validity message for the element. If this message is not the empty string, then the element is suffering from a custom validity error, and does not validate. - {{domxref("HTMLInputElement.setRangeText()", "setRangeText()")}} - : Replaces a range of text in the input element with new text. -- {{domxref("HTMLInputElement.setCustomValidity()", "setCustomValidity()")}} +- {{domxref("HTMLInputElement.setSelectionRange()", "setSelectionRange()")}} - - : Sets a custom validity message for the element. If this message is not the empty string, then the element is suffering from a custom validity error, and does not validate. + - : Selects a range of text in the input element (but does not focus it). - {{domxref("HTMLInputElement.showPicker()", "showPicker()")}} - : Shows a browser picker for date, time, color, and files. -- {{domxref("HTMLInputElement.checkValidity()", "checkValidity()")}} - - - : Returns a boolean value that is `false` if the element is a candidate for constraint validation, and it does not satisfy its constraints. In this case, it also fires an {{domxref("HTMLInputElement/invalid_event", "invalid")}} event at the element. It returns `true` if the element is not a candidate for constraint validation, or if it satisfies its constraints. - -- {{domxref("HTMLInputElement.reportValidity()", "reportValidity()")}} - - - : Runs the `checkValidity()` method, and if it returns false (for an invalid input or no pattern attribute provided), then it reports to the user that the input is invalid in the same manner as if you submitted a form. - - {{domxref("HTMLInputElement.stepDown()", "stepDown()")}} - - : Decrements the [`value`](/en-US/docs/Web/HTML/Element/input#value) by ([`step`](/en-US/docs/Web/HTML/Element/input#step) \* n), where n defaults to 1 if not specified. Throws an `InvalidStateError` exception: - - if the method is not applicable to for the current [`type`](/en-US/docs/Web/HTML/Element/input#type) value, - - if the element has no [`step`](/en-US/docs/Web/HTML/Element/input#step) value, - - if the [`value`](/en-US/docs/Web/HTML/Element/input#value) cannot be converted to a number, - - if the resulting value is above the [`max`](/en-US/docs/Web/HTML/Element/input#max) or below the [`min`](/en-US/docs/Web/HTML/Element/input#min). + - : Decrements the [`value`](/en-US/docs/Web/HTML/Element/input#value) by ([`step`](/en-US/docs/Web/HTML/Element/input#step) \* n), where n defaults to 1 if not specified. - {{domxref("HTMLInputElement.stepUp()", "stepUp()")}} - - : Increments the [`value`](/en-US/docs/Web/HTML/Element/input#value) by ([`step`](/en-US/docs/Web/HTML/Element/input#step) \* n), where n defaults to 1 if not specified. Throws an `InvalidStateError` exception: - - if the method is not applicable to for the current [`type`](/en-US/docs/Web/HTML/Element/input#type) value., - - if the element has no [`step`](/en-US/docs/Web/HTML/Element/input#step) value, - - if the [`value`](/en-US/docs/Web/HTML/Element/input#value) cannot be converted to a number, - - if the resulting value is above the [`max`](/en-US/docs/Web/HTML/Element/input#max) or below the [`min`](/en-US/docs/Web/HTML/Element/input#min). + - : Increments the [`value`](/en-US/docs/Web/HTML/Element/input#value) by ([`step`](/en-US/docs/Web/HTML/Element/input#step) \* n), where n defaults to 1 if not specified. ## Events -Listen to these events using [`addEventListener()`](/en-US/docs/Web/API/EventTarget/addEventListener) or by assigning an event listener to the `oneventname` property of this interface: +_Also inherits events from its parent interface, {{domxref("HTMLElement")}}._ + +Listen to these events using {{domxref("EventTarget.addEventListener", "addEventListener()")}} or by assigning an event listener to the `oneventname` property of this interface: -- [`input`](/en-US/docs/Web/API/HTMLElement/input_event) - - : Fires when the `value` of an {{HTMLElement("input")}}, {{HTMLElement("select")}}, or {{HTMLElement("textarea")}} element has been changed. Note that this is actually fired on the {{domxref("HTMLElement")}} interface and also applies to [`contenteditable`](/en-US/docs/Web/HTML/Global_attributes/contenteditable) elements, but we've listed it here because it is most commonly used with form input elements. -- [`invalid`](/en-US/docs/Web/API/HTMLInputElement/invalid_event) +- {{domxref("HTMLInputElement/invalid_event", "invalid")}} event - : Fired when an element does not satisfy its constraints during constraint validation. -- [`search`](/en-US/docs/Web/API/HTMLInputElement/search_event) {{Non-standard_Inline}} +- {{domxref("HTMLInputElement/search_event", "search")}} event {{Non-standard_Inline}} - : Fired when a search is initiated on an {{HTMLElement("input")}} of `type="search"`. +- {{domxref("HTMLInputElement/select_event", "select")}} event + - : Fired when some text has been selected. - {{domxref("HTMLInputElement/selectionchange_event", "selectionchange")}} event {{Experimental_Inline}} - : Fires when the text selection in a {{HTMLElement("input")}} element has been changed. diff --git a/files/en-us/web/api/htmlinputelement/popovertargetaction/index.md b/files/en-us/web/api/htmlinputelement/popovertargetaction/index.md index 8bdfff44b32ab96..62787f2939db7f9 100644 --- a/files/en-us/web/api/htmlinputelement/popovertargetaction/index.md +++ b/files/en-us/web/api/htmlinputelement/popovertargetaction/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.HTMLInputElement.popoverTargetAction --- -{{ APIRef("DOM") }} +{{APIRef("Popover API")}} The **`popoverTargetAction`** property of the {{domxref("HTMLInputElement")}} interface gets and sets the action to be performed (`"hide"`, `"show"`, or `"toggle"`) on a popover element being controlled by an {{htmlelement("input")}} element of `type="button"`. @@ -134,4 +134,5 @@ The popover can be displayed by selecting the "Show popover" button, and dismiss ## See also +- [`popover`](/en-US/docs/Web/HTML/Global_attributes/popover) HTML global attribute - [Popover API](/en-US/docs/Web/API/Popover_API) diff --git a/files/en-us/web/api/htmlinputelement/popovertargetelement/index.md b/files/en-us/web/api/htmlinputelement/popovertargetelement/index.md index 63c2aeab07a6819..55f79f7e7970319 100644 --- a/files/en-us/web/api/htmlinputelement/popovertargetelement/index.md +++ b/files/en-us/web/api/htmlinputelement/popovertargetelement/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.HTMLInputElement.popoverTargetElement --- -{{ APIRef("DOM") }} +{{APIRef("Popover API")}} The **`popoverTargetElement`** property of the {{domxref("HTMLInputElement")}} interface gets and sets the popover element to control via an {{htmlelement("input")}} element of `type="button"`. @@ -101,4 +101,5 @@ The "auto" popover can also be light dismissed by selecting outside the bounds o ## See also +- [`popover`](/en-US/docs/Web/HTML/Global_attributes/popover) HTML global attribute - [Popover API](/en-US/docs/Web/API/Popover_API) diff --git a/files/en-us/web/api/htmlinputelement/selectiondirection/index.md b/files/en-us/web/api/htmlinputelement/selectiondirection/index.md new file mode 100644 index 000000000000000..56a7d792d00e437 --- /dev/null +++ b/files/en-us/web/api/htmlinputelement/selectiondirection/index.md @@ -0,0 +1,64 @@ +--- +title: "HTMLInputElement: selectionDirection property" +short-title: selectionDirection +slug: Web/API/HTMLInputElement/selectionDirection +page-type: web-api-instance-property +browser-compat: api.HTMLInputElement.selectionDirection +--- + +{{ApiRef("HTML DOM")}} + +The **`selectionDirection`** property of the {{domxref("HTMLInputElement")}} interface is a string that indicates the direction in which the user is selecting the text. + +## Value + +A string. It can have one of the following values: + +- `forward` + - : The user is extending the selection towards the end of the input text. +- `backward` + - : The user is extending the selection towards the start of the input text. +- `none` + - : The user is not extending the selection. + +> **Note:** On Windows, the direction indicates the position of the caret relative to the selection: a "forward" selection has the caret at the end of the selection and a "backward" selection has the caret at the start of the selection. Windows has no "none" direction. + +> **Note:** On Mac, the direction indicates which end of the selection is affected when the user adjusts the size of the selection using the arrow keys with the Shift modifier: the "forward" direction means the end of the selection is modified, and the "backward" direction means the start of the selection is modified. The "none" direction is the default on Mac, it indicates that no particular direction has yet been selected. The user sets the direction implicitly when first adjusting the selection, based on which directional arrow key was used. + +## Examples + +### HTML + +```html + + +

+``` + +### JavaScript + +```js +const textSelectionDirection = document.querySelector("#selectionDirection"); +const pConsole = document.querySelector("#direction"); +pConsole.textContent = + "Selection direction : " + textSelectionDirection.selectionDirection; +``` + +### Result + +{{EmbedLiveSample("Examples")}} + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("HTMLTextAreaElement.selectionDirection")}} property +- {{domxref("HTMLInputElement.selectionStart")}} property +- {{domxref("HTMLInputElement.selectionEnd")}} property +- {{domxref("HTMLInputElement.setSelectionRange")}} method diff --git a/files/en-us/web/api/htmlinputelement/selectionend/index.md b/files/en-us/web/api/htmlinputelement/selectionend/index.md new file mode 100644 index 000000000000000..009749417db335e --- /dev/null +++ b/files/en-us/web/api/htmlinputelement/selectionend/index.md @@ -0,0 +1,75 @@ +--- +title: "HTMLInputElement: selectionEnd property" +short-title: selectionEnd +slug: Web/API/HTMLInputElement/selectionEnd +page-type: web-api-instance-property +browser-compat: api.HTMLInputElement.selectionEnd +--- + +{{ApiRef("HTML DOM")}} + +The **`selectionEnd`** property of the {{domxref("HTMLInputElement")}} interface is a number that represents the end index of the selected text. When there is no selection, this returns the offset of the character immediately following the current text input cursor position. + +> **Note:** According to the [WHATWG forms spec](https://html.spec.whatwg.org/multipage/forms.html#concept-input-apply) `selectionEnd` property applies only to inputs of types text, search, URL, tel, and password. In modern browsers, throws an exception while setting `selectionEnd` property on the rest of input types. Additionally, this property returns `null` while accessing `selectionEnd` property on non-text input elements. + +If `selectionEnd` is less than `selectionStart`, then both are +treated as the value of `selectionEnd`. + +## Value + +A non-negative number. + +## Examples + +### HTML + +```html + + + + + +
+ selectionEnd property on type=text + + + +
+``` + +### JavaScript + +```js +const colorEnd = document.getElementById("color"); +const text = document.querySelector("#pin"); +const pinBtn = document.querySelector("#pin-btn"); +const validPinChecker = /[^\d{3}-\d{2}-\d{3}]/g; +const selectionEnd = text.value.length; +const selectedText = text.value.substring(text.selectionStart, selectionEnd); + +pinBtn.addEventListener("click", () => { + const correctedText = selectedText.replace(validPinChecker, ""); + text.value = correctedText; +}); + +// open browser console to verify output +console.log(colorEnd.selectionEnd); // Output : null +``` + +### Result + +{{EmbedLiveSample("Examples")}} + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("HTMLTextAreaElement.selectionEnd")}} property +- {{domxref("HTMLInputElement.selectionStart")}} property +- {{domxref("HTMLInputElement.setSelectionRange")}} method diff --git a/files/en-us/web/api/htmlinputelement/selectionstart/index.md b/files/en-us/web/api/htmlinputelement/selectionstart/index.md new file mode 100644 index 000000000000000..2936427b1c14600 --- /dev/null +++ b/files/en-us/web/api/htmlinputelement/selectionstart/index.md @@ -0,0 +1,76 @@ +--- +title: "HTMLInputElement: selectionStart property" +short-title: selectionStart +slug: Web/API/HTMLInputElement/selectionStart +page-type: web-api-instance-property +browser-compat: api.HTMLInputElement.selectionStart +--- + +{{ApiRef("HTML DOM")}} + +The **`selectionStart`** property of the {{domxref("HTMLInputElement")}} interface is a number that represents the beginning index of the selected text. When nothing is selected, then returns the position of the text input cursor (caret) inside of the `` element. + +> **Note:** According to the [WHATWG forms spec](https://html.spec.whatwg.org/multipage/forms.html#concept-input-apply) `selectionStart` property applies only to inputs of types text, search, URL, tel, and password. In modern browsers, throws an exception while setting `selectionStart` property on the rest of input types. Additionally, this property returns `null` while accessing `selectionStart` property on non-text input elements. + +If `selectionStart` is greater than `selectionEnd`, then both are +treated as the value of `selectionEnd`. + +## Value + +A non-negative number. + +## Examples + +### HTML + +```html + + + + + +
+ selectionStart property on type=text + + + +
+``` + +### JavaScript + +```js +const inputElement = document.getElementById("statement"); +const statementBtn = document.getElementById("statement-btn"); +const colorStart = document.getElementById("color"); + +statementBtn.addEventListener("click", () => { + inputElement.selectionStart = 4; + inputElement.selectionEnd = 7; + inputElement.focus(); +}); + +// open browser console to verify output +console.log(colorStart.selectionStart); // Output : null +``` + +### Result + +{{EmbedLiveSample("Examples")}} + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("HTMLTextAreaElement.selectionStart")}} property +- {{domxref("HTMLInputElement.selectionEnd")}} property +- {{domxref("HTMLInputElement.setSelectionRange")}} method diff --git a/files/en-us/web/api/htmlinputelement/type/index.md b/files/en-us/web/api/htmlinputelement/type/index.md new file mode 100644 index 000000000000000..72be0ad78107f92 --- /dev/null +++ b/files/en-us/web/api/htmlinputelement/type/index.md @@ -0,0 +1,47 @@ +--- +title: "HTMLInputElement: type property" +short-title: type +slug: Web/API/HTMLInputElement/type +page-type: web-api-instance-property +browser-compat: api.HTMLInputElement.type +--- + +{{ApiRef("HTML DOM")}} + +The **`type`** property of the {{domxref("HTMLInputElement")}} interface indicates the kind of data allowed in the {{HTMLElement("input")}} element, or example a number, a date, or an email. Browsers will select the appropriate widget and behavior to help users to enter a valid value. + +It reflects the [`type`](/en-US/docs/Web/HTML/Element/input#type) attribute of the {{HTMLElement("input")}} element. + +## Value + +A string representing the type. + +Its possible values are listed in the attribute's [input types](/en-US/docs/Web/HTML/Element/input#input_types) section. + +## Example + +### HTML + +```html + +``` + +### JavaScript + +```js +const inputElement = document.querySelector("#input1"); +console.log(inputElement.type); // Output: "date" +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("HTMLTextAreaElement.type")}} property +- {{domxref("HTMLButtonElement.type")}} property diff --git a/files/en-us/web/api/htmllegendelement/index.md b/files/en-us/web/api/htmllegendelement/index.md index b86ce41faf15cbc..1ef9e6d0a631275 100644 --- a/files/en-us/web/api/htmllegendelement/index.md +++ b/files/en-us/web/api/htmllegendelement/index.md @@ -15,12 +15,10 @@ The **`HTMLLegendElement`** is an interface allowing to access properties of the _Inherits properties from its parent, {{domxref("HTMLElement")}}._ -- {{domxref("HTMLLegendElement.form")}} {{ReadOnlyInline}} - - : A {{domxref("HTMLFormElement")}} representing the form that this legend belongs to. If the legend has a fieldset element as its parent, then this attribute returns the same value as the **form** attribute on the parent fieldset element. Otherwise, it returns null. -- {{domxref("HTMLLegendElement.accessKey")}} - - : A string representing a single-character access key to give access to the element. - {{domxref("HTMLLegendElement.align")}} {{deprecated_inline}} - - : A string representing the alignment relative to the form set + - : A string representing the alignment relative to the form set. +- {{domxref("HTMLLegendElement.form")}} {{ReadOnlyInline}} + - : A {{domxref("HTMLFormElement")}} representing the form that this legend belongs to. If the legend has a fieldset element as its parent, then this attribute returns the same value as the **form** attribute on the parent fieldset element. Otherwise, it returns `null`. ## Instance methods diff --git a/files/en-us/web/api/htmllinkelement/crossorigin/index.md b/files/en-us/web/api/htmllinkelement/crossorigin/index.md new file mode 100644 index 000000000000000..0367f655679cead --- /dev/null +++ b/files/en-us/web/api/htmllinkelement/crossorigin/index.md @@ -0,0 +1,38 @@ +--- +title: "HTMLLinkElement: crossOrigin property" +short-title: crossOrigin +slug: Web/API/HTMLLinkElement/crossOrigin +page-type: web-api-instance-property +browser-compat: api.HTMLLinkElement.crossOrigin +--- + +{{APIRef("HTML DOM")}} + +The **`crossOrigin`** property of the {{domxref("HTMLLinkElement")}} interface specifies the Cross-Origin Resource Sharing ({{Glossary("CORS")}}) setting to use when retrieving the resource. + +## Value + +A string of a keyword specifying the CORS mode to use when fetching the resource. Possible values are: + +- `anonymous` or the empty string (`""`) + - : Requests sent by the {{domxref("HTMLLinkElement")}} will use the `cors` {{domxref("Request.mode", "mode", "", "nocode")}} and the `same-origin` {{domxref("Request.credentials", "credentials", "", "nocode")}} mode. This means that CORS is enabled and credentials are sent _if_ the resource is fetched from the same origin from which the document was loaded. +- `use-credentials` + - : Requests sent by the {{domxref("HTMLLinkElement")}} will use the `cors` {{domxref("Request.mode", "mode", "", "nocode")}} and the `include` {{domxref("Request.credentials", "credentials", "", "nocode")}} mode. All resources requests by the element will use CORS, regardless of what domain the fetch is from. + +If the `crossOrigin` property is specified with any other value, it is the same as specifing as the `anonymous`. + +If the `crossOrigin` property is not specified, the resource is fetched without CORS (the `no-cors` {{domxref("Request.mode", "mode", "", "nocode")}} and the `same-origin` {{domxref("Request.credentials", "credentials", "", "nocode")}} mode). + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("HTMLImageElement.crossOrigin")}} +- {{domxref("HTMLMediaElement.crossOrigin")}} +- {{domxref("HTMLScriptElement.crossOrigin")}} diff --git a/files/en-us/web/api/htmllinkelement/hreflang/index.md b/files/en-us/web/api/htmllinkelement/hreflang/index.md new file mode 100644 index 000000000000000..09a39397b1b8f0a --- /dev/null +++ b/files/en-us/web/api/htmllinkelement/hreflang/index.md @@ -0,0 +1,59 @@ +--- +title: "HTMLLinkElement: hreflang property" +short-title: hreflang +slug: Web/API/HTMLLinkElement/hreflang +page-type: web-api-instance-property +browser-compat: api.HTMLLinkElement.hreflang +--- + +{{ApiRef("HTML DOM")}} + +The **`hreflang`** property of the {{domxref("HTMLLinkElement")}} is used to indicate the language and the geographical targeting of a page. This hint can be used by browsers to select the more appropriate page or to improve {{Glossary("SEO")}}. + +It reflects the `hreflang` attribute of the {{HTMLElement("link")}} element and is the empty string (`""`) if there is no `hreflang` attribute. + +## Value + +A string that contains a language tag, or the empty string (`""`) if there is no `hreflang` attribute. + +## Example + +```html + +

+``` + +```css +.tag { + margin-left: 20px; + font: bold; + font-size: 24px; +} +``` + +```js +const myLink = document.querySelector("link"); +const pTag = document.querySelector(".tag"); +pTag.textContent = myLink.hreflang; +``` + +## Results + +{{EmbedLiveSample("Example",100,100)}} + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("HTMLAnchorElement.hreflang")}} property diff --git a/files/en-us/web/api/htmlmapelement/name/index.md b/files/en-us/web/api/htmlmapelement/name/index.md new file mode 100644 index 000000000000000..38228a646f3a36f --- /dev/null +++ b/files/en-us/web/api/htmlmapelement/name/index.md @@ -0,0 +1,44 @@ +--- +title: "HTMLMapElement: name property" +short-title: name +slug: Web/API/HTMLMapElement/name +page-type: web-api-instance-property +browser-compat: api.HTMLMapElement.name +--- + +{{ApiRef("HTML DOM")}} + +The **`name`** property of the {{domxref("HTMLMapElement")}} represents the unique name `` element. +Its value can be used with the `useMap` attribute of the {{HTMLElement("img")}} element to reference a `` element. + +If an `id` attribute is set on the {{HTMLElement("map")}} element, then this `name` property should be the same as this `id`. + +## Value + +A non-empty string without whitespaces. + +## Example + +```html + + + +``` + +```js +const mapElement = document.getElementsByName("image-map")[0]; +console.log(mapElement.name); // output: "image-map" +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("HTMLImageElement.useMap")}} property +- {{domxref("HTMLAreaElement")}} element diff --git a/files/en-us/web/api/htmlmarqueeelement/index.md b/files/en-us/web/api/htmlmarqueeelement/index.md index 8477e88b351df96..63f50e07d5bb438 100644 --- a/files/en-us/web/api/htmlmarqueeelement/index.md +++ b/files/en-us/web/api/htmlmarqueeelement/index.md @@ -42,15 +42,6 @@ _Inherits properties from its parent, {{DOMxRef("HTMLElement")}}._ - {{DOMxRef("HTMLMarqueeElement.width")}} {{Deprecated_Inline}} - : Sets the width in pixels or percentage value. -### Event handlers - -- {{DOMxRef("HTMLMarqueeElement.onbounce")}} {{Deprecated_Inline}} - - : Fires when the marquee has reached the end of its scroll position. It can only fire when the behavior attribute is set to `alternate`. -- {{DOMxRef("HTMLMarqueeElement.onfinish")}} {{Deprecated_Inline}} - - : Fires when the marquee has finished the amount of scrolling that is set by the loop attribute. It can only fire when the loop attribute is set to some number that is greater than 0. -- {{DOMxRef("HTMLMarqueeElement.onstart")}} {{Deprecated_Inline}} - - : Fires when the marquee starts scrolling. - ## Instance methods _Inherits methods from its parent, {{DOMxRef("HTMLElement")}}._ @@ -60,6 +51,15 @@ _Inherits methods from its parent, {{DOMxRef("HTMLElement")}}._ - {{DOMxRef("HTMLMarqueeElement.stop()")}} {{Deprecated_Inline}} - : Stops scrolling of the marquee. +## Events + +- {{DOMxRef("HTMLMarqueeElement/bounce_event", "bounce")}} {{Deprecated_Inline}} + - : Fires when the marquee has reached the end of its scroll position. It can only fire when the behavior attribute is set to `alternate`. +- {{DOMxRef("HTMLMarqueeElement/finish_event", "finish")}} {{Deprecated_Inline}} + - : Fires when the marquee has finished the amount of scrolling that is set by the loop attribute. It can only fire when the loop attribute is set to some number that is greater than 0. +- {{DOMxRef("HTMLMarqueeElement/start_event", "start")}} {{Deprecated_Inline}} + - : Fires when the marquee starts scrolling. + ## Examples ```html diff --git a/files/en-us/web/api/htmlmediaelement/buffered/index.md b/files/en-us/web/api/htmlmediaelement/buffered/index.md index 16aad2f86a5098f..b74575c33296f78 100644 --- a/files/en-us/web/api/htmlmediaelement/buffered/index.md +++ b/files/en-us/web/api/htmlmediaelement/buffered/index.md @@ -10,8 +10,6 @@ browser-compat: api.HTMLMediaElement.buffered The **`buffered`** read-only property of {{domxref("HTMLMediaElement")}} objects returns a new static [normalized `TimeRanges` object](/en-US/docs/Web/API/TimeRanges#normalized_timeranges_objects) that represents the ranges of the media resource, if any, that the user agent has buffered at the moment the `buffered` property is accessed. -> **Note:** This feature is not available in [Web Workers](/en-US/docs/Web/API/Web_Workers_API). - ## Value A new static [normalized TimeRanges object](/en-US/docs/Web/API/TimeRanges#normalized_timeranges_objects) that represents the ranges of the media resource, if any, that the user agent has buffered at the moment the `buffered` property is accessed. diff --git a/files/en-us/web/api/htmlmediaelement/canplaytype/index.md b/files/en-us/web/api/htmlmediaelement/canplaytype/index.md index c9e26f05cae18e8..cc7f995ef99ce57 100644 --- a/files/en-us/web/api/htmlmediaelement/canplaytype/index.md +++ b/files/en-us/web/api/htmlmediaelement/canplaytype/index.md @@ -10,8 +10,6 @@ browser-compat: api.HTMLMediaElement.canPlayType The {{domxref("HTMLMediaElement")}} method **`canPlayType()`** reports how likely it is that the current browser will be able to play media of a given MIME type. -> **Note:** This feature is not available in [Web Workers](/en-US/docs/Web/API/Web_Workers_API). - ## Syntax ```js-nolint diff --git a/files/en-us/web/api/htmlmediaelement/crossorigin/index.md b/files/en-us/web/api/htmlmediaelement/crossorigin/index.md index 80a1dc3785a5070..58ae4e621967e87 100644 --- a/files/en-us/web/api/htmlmediaelement/crossorigin/index.md +++ b/files/en-us/web/api/htmlmediaelement/crossorigin/index.md @@ -10,6 +10,19 @@ browser-compat: api.HTMLMediaElement.crossOrigin The **`HTMLMediaElement.crossOrigin`** property is the CORS setting for this media element. See [CORS settings attributes](/en-US/docs/Web/HTML/Attributes/crossorigin) for details. +## Value + +A string of a keyword specifying the CORS mode to use when fetching the resource. Possible values are: + +- `anonymous` or the empty string (`""`) + - : Requests sent by the {{domxref("HTMLMediaElement")}} will use the `cors` {{domxref("Request.mode", "mode", "", "nocode")}} and the `same-origin` {{domxref("Request.credentials", "credentials", "", "nocode")}} mode. This means that CORS is enabled and credentials are sent _if_ the resource is fetched from the same origin from which the document was loaded. +- `use-credentials` + - : Requests sent by the {{domxref("HTMLMediaElement")}} will use the `cors` {{domxref("Request.mode", "mode", "", "nocode")}} and the `include` {{domxref("Request.credentials", "credentials", "", "nocode")}} mode. All resources requests by the element will use CORS, regardless of what domain the fetch is from. + +If the `crossOrigin` property is specified with any other value, it is the same as specifing as the `anonymous`. + +If the `crossOrigin` property is not specified, the resource is fetched without CORS (the `no-cors` {{domxref("Request.mode", "mode", "", "nocode")}} and the `same-origin` {{domxref("Request.credentials", "credentials", "", "nocode")}} mode). + ## Specifications {{Specifications}} @@ -20,4 +33,6 @@ The **`HTMLMediaElement.crossOrigin`** property is the CORS setting for this med ## See also -- {{domxref("HTMLMediaElement")}}: Interface used to define the `HTMLMediaElement.crossOrigin` property +- {{domxref("HTMLImageElement.crossOrigin")}} +- {{domxref("HTMLLinkElement.crossOrigin")}} +- {{domxref("HTMLScriptElement.crossOrigin")}} diff --git a/files/en-us/web/api/htmlmediaelement/index.md b/files/en-us/web/api/htmlmediaelement/index.md index d3b43b96b0926bc..0436e5b9e003992 100644 --- a/files/en-us/web/api/htmlmediaelement/index.md +++ b/files/en-us/web/api/htmlmediaelement/index.md @@ -119,7 +119,7 @@ _This interface also inherits methods from its ancestors {{domxref("HTMLElement" - : Pauses the media playback. - {{domxref("HTMLMediaElement.play()")}} - : Begins playback of the media. -- {{domxref("HTMLMediaElement.seekToNextFrame()")}} {{Deprecated_Inline}} +- {{domxref("HTMLMediaElement.seekToNextFrame()")}} {{Deprecated_Inline}} {{non-standard_inline}} - : Seeks to the next frame in the media. This non-standard, experimental method makes it possible to manually drive reading and rendering of media at a custom speed, or to move through the media frame-by-frame to perform filtering or other operations. - {{domxref("HTMLMediaElement.setMediaKeys()")}} - : Returns {{jsxref("Promise")}}. Sets the {{domxref("MediaKeys")}} keys to use when decrypting media during playback. @@ -139,7 +139,9 @@ _These methods are obsolete and should not be used, even if a browser still supp ## Events -_Inherits methods from its parent, {{domxref("HTMLElement")}}_. Listen to these events using [`addEventListener()`](/en-US/docs/Web/API/EventTarget/addEventListener) or by assigning an event listener to the `oneventname` property of this interface. +_Inherits events from its parent, {{domxref("HTMLElement")}}_. + +Listen to these events using {{domxref("EventTarget.addEventListener", "addEventListener()")}} or by assigning an event listener to the `oneventname` property of this interface. - {{domxref("HTMLMediaElement.abort_event", 'abort')}} - : Fired when the resource was not fully loaded, but not as the result of an error. diff --git a/files/en-us/web/api/htmlmediaelement/loadstart_event/index.md b/files/en-us/web/api/htmlmediaelement/loadstart_event/index.md index 8a57b2780d1ecfd..c1f5ba3be6f97c7 100644 --- a/files/en-us/web/api/htmlmediaelement/loadstart_event/index.md +++ b/files/en-us/web/api/htmlmediaelement/loadstart_event/index.md @@ -102,7 +102,7 @@ loadVideo.addEventListener("click", () => { source = document.createElement("source"); source.setAttribute( "src", - "https://interactive-examples.mdn.mozilla.net/media/examples/flower.webm", + "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm", ); source.setAttribute("type", "video/webm"); diff --git a/files/en-us/web/api/htmlmediaelement/mediakeys/index.md b/files/en-us/web/api/htmlmediaelement/mediakeys/index.md index afc7c867900f997..3c064777464d34d 100644 --- a/files/en-us/web/api/htmlmediaelement/mediakeys/index.md +++ b/files/en-us/web/api/htmlmediaelement/mediakeys/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.HTMLMediaElement.mediaKeys --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The read-only **`HTMLMediaElement.mediaKeys`** property returns a {{domxref("MediaKeys")}} object, that is a set of keys that the element can use for decryption of media data during playback. diff --git a/files/en-us/web/api/htmlmediaelement/seektonextframe/index.md b/files/en-us/web/api/htmlmediaelement/seektonextframe/index.md index 6f35fff6a103ea6..50ba85c54974fe7 100644 --- a/files/en-us/web/api/htmlmediaelement/seektonextframe/index.md +++ b/files/en-us/web/api/htmlmediaelement/seektonextframe/index.md @@ -5,10 +5,11 @@ slug: Web/API/HTMLMediaElement/seekToNextFrame page-type: web-api-instance-method status: - deprecated + - non-standard browser-compat: api.HTMLMediaElement.seekToNextFrame --- -{{APIRef("HTML DOM")}}{{Deprecated_Header}} +{{APIRef("HTML DOM")}}{{Deprecated_Header}}{{non-standard_header}} The **`HTMLMediaElement.seekToNextFrame()`** method asynchronously advances the current play position to the next frame in the media. diff --git a/files/en-us/web/api/htmlmediaelement/setmediakeys/index.md b/files/en-us/web/api/htmlmediaelement/setmediakeys/index.md index ef8b2cebe3fda60..d4ea70bb2b3df4d 100644 --- a/files/en-us/web/api/htmlmediaelement/setmediakeys/index.md +++ b/files/en-us/web/api/htmlmediaelement/setmediakeys/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.HTMLMediaElement.setMediaKeys --- -{{APIRef("HTML DOM")}} +{{APIRef("HTML DOM")}}{{SecureContext_Header}} The **`setMediaKeys()`** method of the {{domxref("HTMLMediaElement")}} interface returns a {{jsxref("Promise")}} that resolves diff --git a/files/en-us/web/api/htmlmediaelement/setsinkid/index.md b/files/en-us/web/api/htmlmediaelement/setsinkid/index.md index f3e15bf0d3a0482..cdbeb78450a7ea5 100644 --- a/files/en-us/web/api/htmlmediaelement/setsinkid/index.md +++ b/files/en-us/web/api/htmlmediaelement/setsinkid/index.md @@ -6,9 +6,9 @@ page-type: web-api-instance-method browser-compat: api.HTMLMediaElement.setSinkId --- -{{APIRef("HTML DOM")}} +{{APIRef("Audio Output Devices API")}}{{securecontext_header}} -The **`HTMLMediaElement.setSinkId()`** method of the [Audio Output Devices API](/en-US/docs/Web/API/Audio_Output_Devices_API) sets the ID of the audio device to use for output and returns a [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). +The **`HTMLMediaElement.setSinkId()`** method of the [Audio Output Devices API](/en-US/docs/Web/API/Audio_Output_Devices_API) sets the ID of the audio device to use for output and returns a {{jsxref("Promise")}}. This only works when the application is permitted to use the specified device. For more information see the [security requirements](#security_requirements) below. @@ -44,12 +44,12 @@ Access to the API is subject to the following constraints: - The method must be called in a [secure context](/en-US/docs/Web/Security/Secure_Contexts). - Access may be gated by the [`speaker-selection`](/en-US/docs/Web/HTTP/Headers/Permissions-Policy/speaker-selection) HTTP [Permission Policy](/en-US/docs/Web/HTTP/Permissions_Policy). - User permission is required to access a non-default device. - The user grants permission by selecting the device associated with the ID in the prompt displayed by [`MediaDevices.selectAudioOutput()`](/en-US/docs/Web/API/MediaDevices/selectAudioOutput). + The user grants permission by selecting the device associated with the ID in the prompt displayed by {{domxref("MediaDevices.selectAudioOutput()")}}. ## Examples -This example shows how to select an audio output device from the array returned by [`MediaDevices.enumerateDevices()`](/en-US/docs/Web/API/MediaDevices/enumerateDevices), and set it as the sink for audio. -Note that the result of `enumerateDevices()` only includes devices for which user permission is not required or has already been been granted. +This example shows how to select an audio output device from the array returned by {{domxref("MediaDevices.enumerateDevices()")}}, and set it as the sink for audio. +Note that the result of `enumerateDevices()` only includes devices for which user permission is not required or has already been granted. ```js const devices = await navigator.mediaDevices.enumerateDevices(); @@ -69,4 +69,5 @@ console.log(`Audio is being output on ${audio.sinkId}`); ## See also -[`HTMLMediaElement.sinkId`](/en-US/docs/Web/API/HTMLMediaElement/sinkId) +- {{domxref("MediaDevices.selectAudioOutput()")}} +- {{domxref("HTMLMediaElement.sinkId")}} diff --git a/files/en-us/web/api/htmlmediaelement/sinkid/index.md b/files/en-us/web/api/htmlmediaelement/sinkid/index.md index e13a59bfadc87b1..53e991b8a9a4ff6 100644 --- a/files/en-us/web/api/htmlmediaelement/sinkid/index.md +++ b/files/en-us/web/api/htmlmediaelement/sinkid/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.HTMLMediaElement.sinkId --- -{{APIRef("HTML DOM")}} +{{APIRef("Audio Output Devices API")}}{{securecontext_header}} The **`HTMLMediaElement.sinkId`** read-only property of the [Audio Output Devices API](/en-US/docs/Web/API/Audio_Output_Devices_API) returns a string that is the unique ID of the device to be used for playing audio output. @@ -33,4 +33,5 @@ Access to the property is subject to the following constraints: ## See also -[`HTMLMediaElement.setSinkId()`](/en-US/docs/Web/API/HTMLMediaElement/setSinkId) +- {{domxref("MediaDevices.selectAudioOutput()")}} +- {{domxref("HTMLMediaElement.setSinkId()")}} diff --git a/files/en-us/web/api/htmlmenuelement/index.md b/files/en-us/web/api/htmlmenuelement/index.md index bc2ac45fff6eab9..4c7f257587d84f1 100644 --- a/files/en-us/web/api/htmlmenuelement/index.md +++ b/files/en-us/web/api/htmlmenuelement/index.md @@ -7,30 +7,17 @@ browser-compat: api.HTMLMenuElement {{APIRef("HTML DOM")}} -The **`HTMLMenuElement`** interface provides special properties (beyond those defined on the regular {{DOMxRef("HTMLElement")}} interface it also has available to it by inheritance) for manipulating {{HTMLElement("menu")}} elements. +The **`HTMLMenuElement`** interface provides additional properties (beyond those inherited from the {{domxref("HTMLElement")}} interface) for manipulating a {{HTMLElement("menu")}} element. +`` is a semantic alternative to the {{HTMLElement("ul")}} element. {{InheritanceDiagram}} -## Constructor - -- {{DOMxRef("HTMLMenuElement.HTMLMenuElement", "HTMLMenuElement()")}} - - : Returns a newly constructed `HTMLMenuElement`. - ## Instance properties _Inherits properties from its parent, {{domxref("HTMLElement")}}, and its ancestors._ -- `compact` {{deprecated_inline}} - - : A Boolean value determining if the menu displays in a compact way. -- `type` {{deprecated_inline}} {{Non-standard_Inline}} - - : Returns `context` if the menu is a context menu. - This use of the {{HTMLElement("menu")}} element has never been implemented widely - and is now deprecated. -- `label` {{deprecated_inline}} {{Non-standard_Inline}} - - : A string associating the menu with a name, - displayed when the menu is used as a context menu. - This use of the {{HTMLElement("menu")}} element has never been implemented widely - and is now deprecated. +- {{domxref("HTMLMenuElement.compact")}} {{deprecated_inline}} + - : A boolean determining if the menu displays compactly. ## Instance methods diff --git a/files/en-us/web/api/htmlobjectelement/height/index.md b/files/en-us/web/api/htmlobjectelement/height/index.md index 3df5f9bf0cee7b3..6843bc846380755 100644 --- a/files/en-us/web/api/htmlobjectelement/height/index.md +++ b/files/en-us/web/api/htmlobjectelement/height/index.md @@ -24,3 +24,12 @@ A string. ## Browser compatibility {{Compat}} + +## See also + +- {{domxref("HTMLCanvasElement.height")}} +- {{domxref("HTMLEmbedElement.height")}} +- {{domxref("HTMLIFrameElement.height")}} +- {{domxref("HTMLImageElement.height")}} +- {{domxref("HTMLSourceElement.height")}} +- {{domxref("HTMLVideoElement.height")}} diff --git a/files/en-us/web/api/htmlobjectelement/index.md b/files/en-us/web/api/htmlobjectelement/index.md index 3515c7c366eb5c5..a47c45367028ba1 100644 --- a/files/en-us/web/api/htmlobjectelement/index.md +++ b/files/en-us/web/api/htmlobjectelement/index.md @@ -47,7 +47,7 @@ _Inherits properties from its parent, {{domxref("HTMLElement")}}._ - : A string that reflects the [`standby`](/en-US/docs/Web/HTML/Element/object#standby) HTML attribute, specifying a message to display while the object loads. - {{domxref("HTMLObjectElement.type")}} - : A string that reflects the [`type`](/en-US/docs/Web/HTML/Element/object#type) HTML attribute, specifying the MIME type of the resource. -- {{domxref("HTMLObjectElement.useMap")}} +- {{domxref("HTMLObjectElement.useMap")}} {{deprecated_inline}} - : A string that reflects the [`usemap`](/en-US/docs/Web/HTML/Element/object#usemap) HTML attribute, specifying a {{HTMLElement("map")}} element to use. - {{domxref("HTMLObjectElement.validationMessage")}} {{ReadOnlyInline}} - : Returns a string representing a localized message that describes the validation constraints that the control does not satisfy (if any). This is the empty string if the control is not a candidate for constraint validation (`willValidate` is `false`), or it satisfies its constraints. diff --git a/files/en-us/web/api/htmlobjectelement/usemap/index.md b/files/en-us/web/api/htmlobjectelement/usemap/index.md index fe2a04ddb5fc449..82b534bef5434fb 100644 --- a/files/en-us/web/api/htmlobjectelement/usemap/index.md +++ b/files/en-us/web/api/htmlobjectelement/usemap/index.md @@ -3,10 +3,12 @@ title: "HTMLObjectElement: useMap property" short-title: useMap slug: Web/API/HTMLObjectElement/useMap page-type: web-api-instance-property +status: + - deprecated browser-compat: api.HTMLObjectElement.useMap --- -{{APIRef("HTML DOM")}} +{{APIRef("HTML DOM")}}{{deprecated_header}} The **`useMap`** property of the {{domxref("HTMLObjectElement")}} interface returns a string that diff --git a/files/en-us/web/api/htmlobjectelement/width/index.md b/files/en-us/web/api/htmlobjectelement/width/index.md index 3fde8261a4165b7..948022429c1caad 100644 --- a/files/en-us/web/api/htmlobjectelement/width/index.md +++ b/files/en-us/web/api/htmlobjectelement/width/index.md @@ -24,3 +24,12 @@ A string. ## Browser compatibility {{Compat}} + +## See also + +- {{domxref("HTMLCanvasElement.width")}} +- {{domxref("HTMLEmbedElement.width")}} +- {{domxref("HTMLIFrameElement.width")}} +- {{domxref("HTMLImageElement.width")}} +- {{domxref("HTMLSourceElement.width")}} +- {{domxref("HTMLVideoElement.width")}} diff --git a/files/en-us/web/api/htmlprogresselement/max/index.md b/files/en-us/web/api/htmlprogresselement/max/index.md new file mode 100644 index 000000000000000..bde71c58af20665 --- /dev/null +++ b/files/en-us/web/api/htmlprogresselement/max/index.md @@ -0,0 +1,51 @@ +--- +title: "HTMLProgressElement: max property" +short-title: max +slug: Web/API/HTMLProgressElement/max +page-type: web-api-instance-property +browser-compat: api.HTMLProgressElement.max +--- + +{{APIRef("HTML DOM")}} + +The **`max`** property of the {{DOMxRef("HTMLProgressElement")}} interface represents the upper bound of the {{HTMLElement("progress")}} element's range. + +## Value + +A floating point number that is greater than zero. The default value is 1.0. + +## Examples + +### HTML + +```html +Progress: 0% +``` + +### JavaScript + +```js +const pBar = document.getElementById("pBar"); +const span = document.getElementsByTagName("span")[0]; + +console.log(`Default value of max: ${pBar.max}`); + +pBar.max = 100; +pBar.value = 0; + +setInterval(() => { + pBar.value = pBar.value < pBar.max ? pBar.value + 1 : 0; + + span.textContent = Math.trunc(pBar.position * 100); +}, 100); +``` + +{{EmbedLiveSample("Examples", "100%", 30)}} + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/htmlprogresselement/position/index.md b/files/en-us/web/api/htmlprogresselement/position/index.md new file mode 100644 index 000000000000000..845d4483b607c45 --- /dev/null +++ b/files/en-us/web/api/htmlprogresselement/position/index.md @@ -0,0 +1,52 @@ +--- +title: "HTMLProgressElement: position property" +short-title: position +slug: Web/API/HTMLProgressElement/position +page-type: web-api-instance-property +browser-compat: api.HTMLProgressElement.position +--- + +{{APIRef("HTML DOM")}} + +The **`position`** read-only property of the {{DOMxRef("HTMLProgressElement")}} interface returns current progress of the {{HTMLElement("progress")}} element. + +## Value + +For determinate progress bar returns the result of current value decided by max value, i.e., a fraction between `0.0` and `1.0`. + +For indeterminate progress bar the value is always `-1`. + +## Examples + +### HTML + +```html +Determinate Progress bar: Position: +0 +``` + +### JavaScript + +```js +const pBar = document.getElementById("pBar"); +const span = document.getElementsByTagName("span")[0]; + +pBar.max = 100; +pBar.value = 0; + +setInterval(() => { + pBar.value = pBar.value < pBar.max ? pBar.value + 1 : 0; + + span.textContent = pBar.position; +}, 100); +``` + +{{EmbedLiveSample("Examples", "100%", 30)}} + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/htmlprogresselement/value/index.md b/files/en-us/web/api/htmlprogresselement/value/index.md new file mode 100644 index 000000000000000..b894daca67a23f6 --- /dev/null +++ b/files/en-us/web/api/htmlprogresselement/value/index.md @@ -0,0 +1,53 @@ +--- +title: "HTMLProgressElement: value property" +short-title: value +slug: Web/API/HTMLProgressElement/value +page-type: web-api-instance-property +browser-compat: api.HTMLProgressElement.value +--- + +{{APIRef("HTML DOM")}} + +The **`value`** property of the {{DOMxRef("HTMLProgressElement")}} interface represents the current progress of the {{HTMLElement("progress")}} element. + +## Value + +A floating point number. If {{DOMxRef("HTMLProgressElement.max", "max")}} value is not set on the progress bar then value ranges between 0.0 and 1.0. If the `max` value is set then the `value` ranges between `0` and the `max` value. + +If the `value` property is not set on {{DOMxRef("HTMLProgressElement")}} object, then the progress bar remains indeterminate. + +## Examples + +### HTML + +```html +Determinate Progress bar: 0% +
+Indeterminate Progress bar: +``` + +### JavaScript + +```js +const pBar = document.getElementById("pBar"); +const span = document.getElementsByTagName("span")[0]; + +pBar.max = 100; +pBar.value = 0; + +setInterval(() => { + pBar.value = pBar.value < pBar.max ? pBar.value + 1 : 0; + + span.textContent = Math.trunc(pBar.position * 100); +}, 100); +``` + +{{EmbedLiveSample("Examples", "100%", 30)}} + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/htmlscriptelement/crossorigin/index.md b/files/en-us/web/api/htmlscriptelement/crossorigin/index.md new file mode 100644 index 000000000000000..bd70c3973e9e977 --- /dev/null +++ b/files/en-us/web/api/htmlscriptelement/crossorigin/index.md @@ -0,0 +1,38 @@ +--- +title: "HTMLScriptElement: crossOrigin property" +short-title: crossOrigin +slug: Web/API/HTMLScriptElement/crossOrigin +page-type: web-api-instance-property +browser-compat: api.HTMLScriptElement.crossOrigin +--- + +{{APIRef("HTML DOM")}} + +The **`crossOrigin`** property of the {{domxref("HTMLScriptElement")}} interface reflects the {{Glossary("CORS", "Cross-Origin Resource Sharing")}} settings for the script element. For classic scripts from other [origins](/en-US/docs/Glossary/Origin), this controls if full error information will be exposed. For module scripts, it controls the script itself and any script it imports. See [CORS settings attributes](/en-US/docs/Web/HTML/Attributes/crossorigin) for details. + +## Value + +A string of a keyword specifying the CORS mode to use when fetching the resource. Possible values are: + +- `anonymous` or an empty string (`""`) + - : Requests sent by the {{domxref("HTMLScriptElement")}} will use the `cors` {{domxref("Request.mode", "mode", "", "nocode")}} and the `same-origin` {{domxref("Request.credentials", "credentials", "", "nocode")}} mode. This means that CORS is enabled and credentials are sent _if_ the resource is fetched from the same origin from which the document was loaded. +- `use-credentials` + - : Requests sent by the {{domxref("HTMLScriptElement")}} will use the `cors` {{domxref("Request.mode", "mode", "", "nocode")}} and the `include` {{domxref("Request.credentials", "credentials", "", "nocode")}} mode. All resources requests by the element will use CORS, regardless of which domain the fetch is from. + +If the `crossOrigin` property is specified with any other value, it is the same as specifing it as the `anonymous`. + +If the `crossOrigin` property is not specified, the resource is fetched without CORS (the `no-cors` {{domxref("Request.mode", "mode", "", "nocode")}} and the `same-origin` {{domxref("Request.credentials", "credentials", "", "nocode")}} mode). + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("HTMLImageElement.crossOrigin")}} +- {{domxref("HTMLLinkElement.crossOrigin")}} +- {{domxref("HTMLMediaElement.crossOrigin")}} diff --git a/files/en-us/web/api/htmlscriptelement/index.md b/files/en-us/web/api/htmlscriptelement/index.md index 87d94f855f653f8..9d164a980b1b26d 100644 --- a/files/en-us/web/api/htmlscriptelement/index.md +++ b/files/en-us/web/api/htmlscriptelement/index.md @@ -40,7 +40,7 @@ _Inherits properties from its parent, {{domxref("HTMLElement")}}._ > **Note:** The exact processing details for these attributes are complex, involving many different aspects of HTML, and therefore are scattered throughout the specification. [These algorithms](https://html.spec.whatwg.org/multipage/scripting.html) describe the core ideas, but they rely on the parsing rules for {{HTMLElement("script")}} [start](https://html.spec.whatwg.org/multipage/syntax.html#start-tags) and [end](https://html.spec.whatwg.org/multipage/syntax.html#end-tags) tags in HTML, [in foreign content](https://html.spec.whatwg.org/multipage/syntax.html#foreign-elements), and [in XML](https://html.spec.whatwg.org/multipage/xhtml.html); the rules for the [`document.write()`](/en-US/docs/Web/API/Document/write) method; the handling of [scripting](https://html.spec.whatwg.org/multipage/webappapis.html); and so on. - {{domxref("HTMLScriptElement.crossOrigin")}} - - : A string reflecting the [CORS setting](/en-US/docs/Web/HTML/Attributes/crossorigin) for the script element. For scripts from other [origins](/en-US/docs/Glossary/Origin), this controls if error information will be exposed. + - : A string reflecting the [CORS setting](/en-US/docs/Web/HTML/Attributes/crossorigin) for the script element. For classic scripts from other [origins](/en-US/docs/Glossary/Origin), this controls if error information will be exposed. - {{domxref("HTMLScriptElement.text")}} - : A string that joins and returns the contents of all [`Text` nodes](/en-US/docs/Web/API/Text) inside the {{HTMLElement("script")}} element (ignoring other nodes like comments) in tree order. On setting, it acts the same way as the [`textContent`](/en-US/docs/Web/API/Node/textContent) IDL attribute. diff --git a/files/en-us/web/api/htmlselectelement/autofocus/index.md b/files/en-us/web/api/htmlselectelement/autofocus/index.md deleted file mode 100644 index d77699480b77153..000000000000000 --- a/files/en-us/web/api/htmlselectelement/autofocus/index.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: "HTMLSelectElement: autofocus property" -short-title: autofocus -slug: Web/API/HTMLSelectElement/autofocus -page-type: web-api-instance-property -browser-compat: api.HTMLSelectElement.autofocus ---- - -{{ APIRef("HTML DOM") }} - -The **`HTMLSelectElement.autofocus`** property has a value of either `true` or `false` that reflects the [`autofocus`](/en-US/docs/Web/HTML/Element/select#autofocus) HTML -attribute, which indicates whether the associated {{HTMLElement("select")}} element -will get input focus when the page loads, unless the user overrides it. - -Only one form-associated element in a document can have this attribute specified. If -there are several, the first element with the attribute set inserted, usually the first -such element on the page, get the initial focus. - -> **Note:** Setting this property doesn't set the focus to the associated -> {{HTMLElement("select")}} element: it merely tells the browser to focus to it when -> _the element is inserted_ in the document. Setting it after the insertion, that -> is most of the time after the document load, has no visible effect. - -## Value - -A boolean value. - -## Examples - -### HTML - -```html - -``` - -### JavaScript - -```js -// Check if the autofocus attribute on the +``` + +### JavaScript + +```js +const txtAreaElement = document.querySelector("#txtarea"); +console.log(txtAreaElement.type); // Output: "textarea" +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("HTMLInputElement.type")}} property diff --git a/files/en-us/web/api/htmltitleelement/index.md b/files/en-us/web/api/htmltitleelement/index.md index da36f8e4cd24923..056a6c8146cdb2b 100644 --- a/files/en-us/web/api/htmltitleelement/index.md +++ b/files/en-us/web/api/htmltitleelement/index.md @@ -16,26 +16,7 @@ The **`HTMLTitleElement`** interface is implemented by a document's {{ HTMLEleme _Inherits properties from its parent, {{domxref("HTMLElement")}}._ - {{domxref("HTMLTitleElement.text")}} - - : A string representing the text of the document's title, and only the text part. For example, consider this: - -```html - - - - - Hello world! <span class="highlight">Isn't this wonderful</span> really? - - - - -``` - -```js -const title = document.querySelector("title"); -console.log(title.text); // yield: "Hello world! really?" -``` - -As you can see, the tag `span` and its content were skipped. + - : A string representing the text of the document's title. ## Instance methods diff --git a/files/en-us/web/api/htmltitleelement/text/index.md b/files/en-us/web/api/htmltitleelement/text/index.md new file mode 100644 index 000000000000000..e605bee14da2b2c --- /dev/null +++ b/files/en-us/web/api/htmltitleelement/text/index.md @@ -0,0 +1,46 @@ +--- +title: "HTMLTitleElement: text property" +short-title: text +slug: Web/API/HTMLTitleElement/text +page-type: web-api-instance-property +browser-compat: api.HTMLTitleElement.text +--- + +{{APIRef("HTML DOM")}} + +The **`text`** property of the {{domxref("HTMLTitleElement")}} interface represents the text of the document's title. Only the text part is included; tags within the element and their content are stripped and ignored. + +## Value + +A string. + +## Examples + +Consider the example below: + +```html + + + + + Hello world! <span class="highlight">Isn't this wonderful</span> really? + + + + +``` + +```js +const title = document.querySelector("title"); +console.log(title.text); // yield: "Hello world! really?" +``` + +As you can see, the tag `span` and its content were skipped. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/htmltrackelement/index.md b/files/en-us/web/api/htmltrackelement/index.md index 66f1d6509a55953..6037863307f7ea9 100644 --- a/files/en-us/web/api/htmltrackelement/index.md +++ b/files/en-us/web/api/htmltrackelement/index.md @@ -45,7 +45,9 @@ _No specific method; inherits methods from its parent, {{domxref("HTMLElement")} ## Events -_The following events may be fired on a {{HTMLElement("track")}} element, in addition to any that may be fired at its parent, {{domxref("HTMLElement")}}._ +_Inherits events from its parent, {{domxref("HTMLElement")}}._ + +Listen to these events using {{domxref("EventTarget/addEventListener", "addEventListener()")}} or by assigning an event listener to the `oneventname` property of this interface: - {{domxref("HTMLTrackElement.cuechange_event", "cuechange")}} - : Sent when the underlying {{domxref("TextTrack")}} has changed the currently-presented cues. This event is always sent to the `TextTrack` but is _also_ sent to the `HTMLTrackElement` if one is associated with the track. diff --git a/files/en-us/web/api/htmlvideoelement/cancelvideoframecallback/index.md b/files/en-us/web/api/htmlvideoelement/cancelvideoframecallback/index.md new file mode 100644 index 000000000000000..58eb02605c10e36 --- /dev/null +++ b/files/en-us/web/api/htmlvideoelement/cancelvideoframecallback/index.md @@ -0,0 +1,67 @@ +--- +title: "HTMLVideoElement: cancelVideoFrameCallback() method" +short-title: cancelVideoFrameCallback() +slug: Web/API/HTMLVideoElement/cancelVideoFrameCallback +page-type: web-api-instance-method +browser-compat: api.HTMLVideoElement.cancelVideoFrameCallback +--- + +{{APIRef("HTML DOM")}} + +The **`cancelVideoFrameCallback()`** method of the {{domxref("HTMLVideoElement")}} interface cancels a previously-registered video frame callback. + +## Syntax + +```js-nolint +cancelVideoFrameCallback(id) +``` + +### Parameters + +- `id` + - : A number representing the ID of the video frame callback you want to cancel. This will be the value returned by the corresponding {{DOMxRef("HTMLVideoElement.requestVideoFrameCallback")}} call. + +### Return value + +None ({{jsxref("undefined")}}). + +## Examples + +### Canceling a video frame callback + +This example shows how to use `cancelVideoFrameCallback()` to cancel a previously-registered video frame callback. + +```js +const updateCanvas = (now, metadata) => { + // Do something with the frame + + // ... + + // Re-register the callback to run on the next frame + // It's important to update the videoCallbackId on each iteration + // so you can cancel the callback successfully + videoCallbackId = video.requestVideoFrameCallback(updateCanvas); +}; + +// Initial registration of the callback to run on the first frame +let videoCallbackId = video.requestVideoFrameCallback(updateCanvas); + +// ... + +// Cancel video frame callback using the latest videoCallbackId +video.cancelVideoFrameCallback(videoCallbackId); +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- The {{HTMLElement("video")}} element +- {{DOMxRef("HTMLVideoElement.requestVideoFrameCallback()")}} +- [Perform efficient per-video-frame operations on video with `requestVideoFrameCallback()`](https://web.dev/articles/requestvideoframecallback-rvfc) on developer.chrome.com (2023) diff --git a/files/en-us/web/api/htmlvideoelement/height/index.md b/files/en-us/web/api/htmlvideoelement/height/index.md new file mode 100644 index 000000000000000..03f7c92be5d5898 --- /dev/null +++ b/files/en-us/web/api/htmlvideoelement/height/index.md @@ -0,0 +1,43 @@ +--- +title: "HTMLVideoElement: height property" +short-title: height +slug: Web/API/HTMLVideoElement/height +page-type: web-api-instance-property +browser-compat: api.HTMLVideoElement.height +--- + +{{APIRef("HTML DOM")}} + +The **`height`** property of the {{domxref("HTMLVideoElement")}} interface returns an integer that reflects the `height` attribute of the {{HTMLElement("video")}} element, specifying the displayed height of the resource in CSS pixels. + +## Value + +A positive integer or 0. + +## Examples + +```html + +``` + +```js +const el = document.getElementById("media"); +console.log(el.height); // Output: 600 +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("HTMLCanvasElement.height")}} +- {{domxref("HTMLEmbedElement.height")}} +- {{domxref("HTMLIFrameElement.height")}} +- {{domxref("HTMLImageElement.height")}} +- {{domxref("HTMLObjectElement.height")}} +- {{domxref("HTMLSourceElement.height")}} diff --git a/files/en-us/web/api/htmlvideoelement/index.md b/files/en-us/web/api/htmlvideoelement/index.md index f32dddf853726fb..2d54f765c92c674 100644 --- a/files/en-us/web/api/htmlvideoelement/index.md +++ b/files/en-us/web/api/htmlvideoelement/index.md @@ -15,8 +15,10 @@ The list of [supported media formats](/en-US/docs/Web/Media/Formats) varies from ## Instance properties -_Inherits properties from its ancestor interfaces, {{domxref("HTMLMediaElement")}}, and {{domxref("HTMLElement")}}._ +_Inherits properties from its parent interface, {{domxref("HTMLMediaElement")}}, and {{domxref("HTMLElement")}}._ +- {{DOMxRef("HTMLVideoElement.disablePictureInPicture")}} + - : Indicates if the user agent should suggest the picture-in-picture to users, or not. - {{domxref("HTMLVideoElement.height")}} - : A string that reflects the [`height`](/en-US/docs/Web/HTML/Element/video#height) HTML attribute, which specifies the height of the display area, in CSS pixels. - {{domxref("HTMLVideoElement.poster")}} @@ -27,8 +29,6 @@ _Inherits properties from its ancestor interfaces, {{domxref("HTMLMediaElement") - : Returns an unsigned integer value indicating the intrinsic width of the resource in CSS pixels, or 0 if no media is available yet. - {{domxref("HTMLVideoElement.width")}} - : A string that reflects the [`width`](/en-US/docs/Web/HTML/Element/video#width) HTML attribute, which specifies the width of the display area, in CSS pixels. -- {{DOMxRef("HTMLVideoElement.disablePictureInPicture")}} - - : The `disablePictureInPicture` property will hint the user agent to not suggest the picture-in-picture to users or to request it automatically ### Gecko-specific properties @@ -47,21 +47,27 @@ _Inherits properties from its ancestor interfaces, {{domxref("HTMLMediaElement") ## Instance methods -_Inherits methods from its parent, {{domxref("HTMLMediaElement")}}, and from its ancestor {{domxref("HTMLElement")}}._ +_Inherits methods from its parent interface, {{domxref("HTMLMediaElement")}}, and {{domxref("HTMLElement")}}._ +- {{DOMxRef("HTMLVideoElement.cancelVideoFrameCallback()")}} + - : Cancels a previously-registered video frame callback (see {{DOMxRef("HTMLVideoElement.requestVideoFrameCallback", "requestVideoFrameCallback()")}}). - {{domxref("HTMLVideoElement.getVideoPlaybackQuality()")}} - : Returns a {{domxref("VideoPlaybackQuality")}} object that contains the current playback metrics. This information includes things like the number of dropped or corrupted frames, as well as the total number of frames. - {{DOMxRef("HTMLVideoElement.requestPictureInPicture()")}} - - : Requests that the user agent make video enters picture-in-picture mode + - : Requests that the user agent enters the video into picture-in-picture mode. +- {{DOMxRef("HTMLVideoElement.requestVideoFrameCallback()")}} + - : Registers a callback function that runs when a new video frame is sent to the compositor. This enables developers to perform efficient operations on each video frame. ## Events -_Inherits events from its parent, {{domxref("HTMLMediaElement")}}, and from its ancestor {{domxref("HTMLElement")}}._ Listen to these events using [`addEventListener()`](/en-US/docs/Web/API/EventTarget/addEventListener) or by assigning an event listener to the `oneventname` property of this interface. +_Inherits events from its parent interface, {{domxref("HTMLMediaElement")}}, and {{domxref("HTMLElement")}}._ + +Listen to these events using {{domxref("EventTarget.addEventListener", "addEventListener()")}} or by assigning an event listener to the `oneventname` property of this interface. - {{DOMxRef("HTMLVideoElement.enterpictureinpicture_event", "enterpictureinpicture")}} - - : Sent to a {{DOMxRef("HTMLVideoElement")}} when it enters Picture-in-Picture mode. + - : Fired when the `HTMLVideoElement` enters picture-in-picture mode successfully. - {{DOMxRef("HTMLVideoElement.leavepictureinpicture_event", "leavepictureinpicture")}} - - : Sent to a {{DOMxRef("HTMLVideoElement")}} when it leaves Picture-in-Picture mode. + - : Fired when the `HTMLVideoElement` leaves picture-in-picture mode successfully. ## Specifications diff --git a/files/en-us/web/api/htmlvideoelement/poster/index.md b/files/en-us/web/api/htmlvideoelement/poster/index.md new file mode 100644 index 000000000000000..a1e6ea94413af4d --- /dev/null +++ b/files/en-us/web/api/htmlvideoelement/poster/index.md @@ -0,0 +1,39 @@ +--- +title: "HTMLVideoElement: poster property" +short-title: poster +slug: Web/API/HTMLVideoElement/poster +page-type: web-api-instance-property +browser-compat: api.HTMLVideoElement.poster +--- + +{{APIRef("HTML DOM")}} + +The **`poster`** property of the {{domxref("HTMLVideoElement")}} interface is a string that reflects the URL for an image to be shown while no video data is available. If the property does not represent a valid URL, no poster frame will be shown. + +It reflects the `poster` attribute of the {{HTMLElement("video")}} element. + +## Value + +A string. + +## Examples + +```html + +``` + +```js +const el = document.getElementById("media"); +console.log(el.poster); // Output: "https://example.com/poster.jpg" +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/htmlvideoelement/requestvideoframecallback/index.md b/files/en-us/web/api/htmlvideoelement/requestvideoframecallback/index.md new file mode 100644 index 000000000000000..3b50506e89d8efb --- /dev/null +++ b/files/en-us/web/api/htmlvideoelement/requestvideoframecallback/index.md @@ -0,0 +1,117 @@ +--- +title: "HTMLVideoElement: requestVideoFrameCallback() method" +short-title: requestVideoFrameCallback() +slug: Web/API/HTMLVideoElement/requestVideoFrameCallback +page-type: web-api-instance-method +browser-compat: api.HTMLVideoElement.requestVideoFrameCallback +--- + +{{APIRef("HTML DOM")}} + +The **`requestVideoFrameCallback()`** method of the {{domxref("HTMLVideoElement")}} interface registers a callback function that runs when a new video frame is sent to the compositor. This enables developers to perform efficient operations on each video frame. + +## Description + +Typical use cases for `requestVideoFrameCallback()` include video processing and painting to a canvas, video analysis, and synchronization with external audio sources. Per-frame processing used to be done in a less efficient or accurate fashion by running operations on the current video display whenever the {{domxref("HTMLMediaElement.timeupdate_event", "timeupdate")}} event fired. This technique did not provide access to the actual video frames. + +`requestVideoFrameCallback()` is used in the same way as {{domxref("Window.requestAnimationFrame()")}}. You use it to run a callback function that performs some operation when the next video frame is sent to the compositor. The callback finishes by calling `requestVideoFrameCallback()` again to run the callback when the next video frame is composited, and so on. However, `requestVideoFrameCallback()` is tailored for video operations in several ways: + +- `requestVideoFrameCallback()` provides reliable access to each individual video frame. +- `requestAnimationFrame()` tries to match the display refresh rate, which is typically 60Hz. `requestVideoFrameCallback()`, on the other hand, tries to match the video frame rate. More specifically, the callback will run at the lower of the video frame rate and the browser paint refresh rate. For example, a video with a frame rate of 25fps playing in a browser that paints at 60Hz would fire callbacks at a rate of 25Hz. A video with a frame rate of 120fps running in the same 60Hz browser would fire callbacks at 60Hz. +- `requestVideoFrameCallback()` makes useful video metadata available in the callback function. + +One thing to bear in mind is that `requestVideoFrameCallback()` does not offer any strict guarantees that the output from your callback will remain in sync with the video frame rate. It may end up being fired one vertical synchronization (v-sync) later than when the new video frame was presented. (V-sync is a graphics technology that synchronizes the frame rate of a video with the refresh rate of a monitor.) + +The API runs on the main thread, while video compositing likely happens on a separate compositing thread. You've got to factor in the time taken for these operations to complete, as well as the time it takes for the video itself and the result of your `requestVideoFrameCallback()` operation to display on the screen. + +You can compare the `now` callback parameter and the `expectedDisplayTime` metadata property to determine whether your callback is a v-sync late. If `expectedDisplayTime` is within about five to ten microseconds of `now`, the frame is already rendered. If the `expectedDisplayTime` is approximately sixteen milliseconds in the future (assuming your browser/screen is refreshing at 60Hz), then the callback is a v-sync out. + +## Syntax + +```js-nolint +requestVideoFrameCallback(callback) +``` + +### Parameters + +- `callback` + + - : The callback function that runs when a new video frame is sent to the compositor. This contains two parameters: + + - `now` + - : A {{domxref("DOMHighResTimeStamp")}} representing the time when the callback was called. + - `metadata` + + - : An object containing the following properties: + + - `expectedDisplayTime`: A {{domxref("DOMHighResTimeStamp")}} representing the time when the browser expects the frame to be visible. + - `height`: A number, in media pixels, representing the height of the video frame (the visible decoded pixels, without aspect ratio adjustments). + - `mediaTime`: A number, in seconds, representing the media presentation timestamp of the presented frame. This is equal to the frame's timestamp on the {{domxref("HTMLMediaElement.currentTime")}} timeline. + - `presentationTime`: A {{domxref("DOMHighResTimeStamp")}} representing the time when the browser submitted the frame for composition. + - `presentedFrames`: A number representing the number of frames submitted for composition so far alongside the current callback. This can be used to detect whether frames were missed between callback instances. + - `processingDuration`: A number, in seconds, representing the duration between the submission of the encoded packet with the same presentation timestamp as this frame to the decoder (i.e., the `mediaTime`) and the decoded frame being ready for presentation. + - `width`: A number, in media pixels, representing the width of the video frame (the visible decoded pixels, without aspect ratio adjustments). + + Additional metadata properties may be available within `requestVideoFrameCallback()` callbacks used in {{domxref("WebRTC_API", "WebRTC", "", "nocode")}} applications: + + - `captureTime`: A {{domxref("DOMHighResTimeStamp")}} representing the time when the frame was captured. This applies to video frames coming from a local or remote source. For a remote source, the capture time is estimated using clock synchronization and RTCP sender reports to convert RTP timestamps to capture time. + - `receiveTime`: A {{domxref("DOMHighResTimeStamp")}} representing the time when the encoded frame was received by the platform. This applies to video frames coming from a remote source. Specifically, this corresponds to the time when the last packet belonging to this frame was received over the network. + - `rtpTimestamp`: A number representing the RTP timestamp associated with this video frame. + +> **Note:** `width` and `height` may differ from {{domxref("HTMLVideoElement.videoWidth")}} and {{domxref("HTMLVideoElement.videoHeight")}} in certain cases (for example, an anamorphic video may have rectangular pixels). + +### Return value + +A number representing a unique callback ID. + +This can be passed to {{DOMxRef("HTMLVideoElement.cancelVideoFrameCallback()")}} to cancel the callback registration. + +## Examples + +### Drawing video frames on a canvas + +This example shows how to use `requestVideoFrameCallback()` to draw the frames of a video onto a {{htmlelement("canvas")}} element at exactly the same frame rate as the video. It also logs the frame metadata to the DOM for debugging purposes. + +```js +if ("requestVideoFrameCallback" in HTMLVideoElement.prototype) { + let paintCount = 0; + let startTime = 0.0; + + const updateCanvas = (now, metadata) => { + if (startTime === 0.0) { + startTime = now; + } + + ctx.drawImage(video, 0, 0, canvas.width, canvas.height); + + const elapsed = (now - startTime) / 1000.0; + const fps = (++paintCount / elapsed).toFixed(3); + fpsInfo.innerText = `video fps: ${fps}`; + metadataInfo.innerText = JSON.stringify(metadata, null, 2); + + // Re-register the callback to run on the next frame + video.requestVideoFrameCallback(updateCanvas); + }; + + // Initial registration of the callback to run on the first frame + video.requestVideoFrameCallback(updateCanvas); +} else { + alert("Your browser does not support requestVideoFrameCallback()."); +} +``` + +See [requestVideoFrameCallback Demo](https://requestvideoframecallback.glitch.me/) for a working implementation of the above code. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- The {{HTMLElement("video")}} element +- {{DOMxRef("HTMLVideoElement.cancelVideoFrameCallback()")}} +- [Perform efficient per-video-frame operations on video with `requestVideoFrameCallback()`](https://web.dev/articles/requestvideoframecallback-rvfc) on developer.chrome.com (2023) diff --git a/files/en-us/web/api/htmlvideoelement/width/index.md b/files/en-us/web/api/htmlvideoelement/width/index.md new file mode 100644 index 000000000000000..f5a0e8c32da8005 --- /dev/null +++ b/files/en-us/web/api/htmlvideoelement/width/index.md @@ -0,0 +1,43 @@ +--- +title: "HTMLVideoElement: width property" +short-title: width +slug: Web/API/HTMLVideoElement/width +page-type: web-api-instance-property +browser-compat: api.HTMLVideoElement.width +--- + +{{APIRef("HTML DOM")}} + +The **`width`** property of the {{domxref("HTMLVideoElement")}} interface returns an integer that that reflects the `width` attribute of the {{HTMLElement("video")}} element, specifying the displayed width of the resource in CSS pixels. + +## Value + +A positive integer or 0. + +## Examples + +```html + +``` + +```js +const el = document.getElementById("media"); +console.log(el.width); // Output: 800 +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- {{domxref("HTMLCanvasElement.width")}} +- {{domxref("HTMLEmbedElement.width")}} +- {{domxref("HTMLIFrameElement.width")}} +- {{domxref("HTMLImageElement.width")}} +- {{domxref("HTMLObjectElement.width")}} +- {{domxref("HTMLSourceElement.width")}} diff --git a/files/en-us/web/api/idbfactory/deletedatabase/index.md b/files/en-us/web/api/idbfactory/deletedatabase/index.md index 3e8739fb54e9005..944225d7d60d151 100644 --- a/files/en-us/web/api/idbfactory/deletedatabase/index.md +++ b/files/en-us/web/api/idbfactory/deletedatabase/index.md @@ -42,7 +42,7 @@ deleteDatabase(name, options) database that doesn't exist does not throw an exception, in contrast to {{DOMxRef("IDBDatabase.deleteObjectStore()")}}, which does throw an exception if the named object store does not exist. -- `options` {{optional_inline}} {{NonStandardBadge}} +- `options` {{optional_inline}} {{Non-standard_Inline}} - : In Gecko, since [version 26](/en-US/docs/Mozilla/Firefox/Releases/26), you can include a non-standard optional storage parameter that specifies whether you want to delete a `permanent` (the default value) IndexedDB, or an indexedDB in diff --git a/files/en-us/web/api/idbindex/index.md b/files/en-us/web/api/idbindex/index.md index 476f9d9467e9ee4..6e65ca3ebc5c877 100644 --- a/files/en-us/web/api/idbindex/index.md +++ b/files/en-us/web/api/idbindex/index.md @@ -19,9 +19,9 @@ You can grab a set of keys within a range. To learn more, see {{domxref("IDBKeyR ## Instance properties -- {{domxref("IDBIndex.isAutoLocale")}} {{ReadOnlyInline}} {{ Non-Standard_inline() }} {{Experimental_Inline}} +- {{domxref("IDBIndex.isAutoLocale")}} {{ReadOnlyInline}} {{ non-standard_inline }} {{deprecated_inline}} - : Returns a boolean value indicating whether the index had a `locale` value of `auto` specified upon its creation (see the [`options`](/en-US/docs/Web/API/IDBObjectStore/createIndex#options) parameter to [`IDBObjectStore.createIndex()`](/en-US/docs/Web/API/IDBObjectStore/createIndex).) -- {{domxref("IDBIndex.locale")}} {{ReadOnlyInline}} {{ Non-Standard_inline() }} {{Experimental_Inline}} +- {{domxref("IDBIndex.locale")}} {{ReadOnlyInline}} {{ non-standard_inline }} {{deprecated_inline}} - : Returns the locale of the index (for example `en-US`, or `pl`) if it had a `locale` value specified upon its creation (see the [`options`](/en-US/docs/Web/API/IDBObjectStore/createIndex#options) parameter to [`IDBObjectStore.createIndex()`](/en-US/docs/Web/API/IDBObjectStore/createIndex).) - {{domxref("IDBIndex.name")}} - : The name of this index. diff --git a/files/en-us/web/api/idbindex/isautolocale/index.md b/files/en-us/web/api/idbindex/isautolocale/index.md index cf514e427ddf829..988af9fbd30cb61 100644 --- a/files/en-us/web/api/idbindex/isautolocale/index.md +++ b/files/en-us/web/api/idbindex/isautolocale/index.md @@ -4,12 +4,12 @@ short-title: isAutoLocale slug: Web/API/IDBIndex/isAutoLocale page-type: web-api-instance-property status: - - experimental + - deprecated - non-standard browser-compat: api.IDBIndex.isAutoLocale --- -{{APIRef("IndexedDB")}}{{SeeCompatTable}}{{Non-standard_Header}} +{{APIRef("IndexedDB")}}{{deprecated_header}}{{non-standard_header}} The **`isAutoLocale`** read-only property of the {{domxref("IDBIndex")}} interface returns a boolean value indicating whether the index had a `locale` value of `auto` specified upon its creation (see the [`options`](/en-US/docs/Web/API/IDBObjectStore/createIndex#options) parameter to [`IDBObjectStore.createIndex()`](/en-US/docs/Web/API/IDBObjectStore/createIndex).) diff --git a/files/en-us/web/api/idbindex/locale/index.md b/files/en-us/web/api/idbindex/locale/index.md index a7dd08400623cbf..7accf6b94be4603 100644 --- a/files/en-us/web/api/idbindex/locale/index.md +++ b/files/en-us/web/api/idbindex/locale/index.md @@ -4,12 +4,12 @@ short-title: locale slug: Web/API/IDBIndex/locale page-type: web-api-instance-property status: - - experimental + - deprecated - non-standard browser-compat: api.IDBIndex.locale --- -{{APIRef("IndexedDB")}}{{SeeCompatTable}}{{Non-standard_Header}} +{{APIRef("IndexedDB")}}{{deprecated_header}}{{non-standard_header}} The **`locale`** read-only property of the {{domxref("IDBIndex")}} interface returns the locale of the index (for example `en-US`, or `pl`) if it had a `locale` value specified upon its creation (see the [`options`](/en-US/docs/Web/API/IDBObjectStore/createIndex#options) parameter to [`IDBObjectStore.createIndex()`](/en-US/docs/Web/API/IDBObjectStore/createIndex).) Note that this property always returns the current locale being used in this index, in other words, it never returns `"auto"`. diff --git a/files/en-us/web/api/idblocaleawarekeyrange/index.md b/files/en-us/web/api/idblocaleawarekeyrange/index.md deleted file mode 100644 index b3032a195b5ef32..000000000000000 --- a/files/en-us/web/api/idblocaleawarekeyrange/index.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -title: IDBLocaleAwareKeyRange -slug: Web/API/IDBLocaleAwareKeyRange -page-type: web-api-interface -status: - - experimental - - non-standard -browser-compat: api.IDBLocaleAwareKeyRange ---- - -{{APIRef("IndexedDB")}}{{SeeCompatTable}}{{Non-standard_Header}} - -The **`IDBLocaleAwareKeyRange`** interface of the [IndexedDB API](/en-US/docs/Web/API/IndexedDB_API) is a Firefox-specific version of {{domxref("IDBKeyRange")}} — it functions in exactly the same fashion, and has the same properties and methods, but it is intended for use with {{domxref("IDBIndex")}} objects when the original index had a `locale` value specified upon its creation (see the [`options`](/en-US/docs/Web/API/IDBObjectStore/createIndex#options) parameter to [`IDBObjectStore.createIndex()`](/en-US/docs/Web/API/IDBObjectStore/createIndex)) — that is, it has [locale aware sorting](/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB#locale-aware_sorting) enabled. - -## Instance methods - -_This interface inherits all the methods of its parent interface, {{domxref("IDBKeyRange")}}._ - -## Instance properties - -_This interface inherits all the properties of its parent interface, {{domxref("IDBKeyRange")}}._ - -Bear in mind however that `IDBLocaleAwareKeyRange` has its own implementation of {{domxref("IDBKeyRange.bound_static", "IDBKeyRange.bound()")}}. This is because when you use `bound()`, it checks if lower bound < upper bound, and throws an exception if that's not the case. With locale-aware indexes, the meaning of < depends on the locale, so for example in Lithuanian Y is sorted between I and K. The only difference between `IDBKeyRange` and `IDBLocaleAwareKeyRange` is that the latter doesn't do the aforementioned check. - -Developers should always use `IDBLocaleAwareKeyRange` when dealing with locale-aware indexes. - -## Examples - -```js -function displayData() { - const keyRangeValue = IDBLocaleAwareKeyRange.bound("A", "F"); - - const transaction = db.transaction(["fThings"], "readonly"); - const objectStore = transaction.objectStore("fThings"); - - const myIndex = objectStore.index("lName"); - myIndex.openCursor(keyRangeValue).onsuccess = (event) => { - const cursor = event.target.result; - if (cursor) { - const tableRow = document.createElement("tr"); - tableRow.innerHTML = - `${cursor.value.id}` + - `${cursor.value.lName}` + - `${cursor.value.fName}` + - `${cursor.value.jTitle}` + - `${cursor.value.company}` + - `${cursor.value.eMail}` + - `${cursor.value.phone}` + - `${cursor.value.age}`; - tableEntry.appendChild(tableRow); - - cursor.continue(); - } else { - console.log("Entries all displayed."); - } - }; -} -``` - -## Specifications - -Not currently part of any specification. - -## Browser compatibility - -{{Compat}} - -## See also - -- [Using IndexedDB](/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB) -- Starting transactions: {{domxref("IDBDatabase")}} -- Using transactions: {{domxref("IDBTransaction")}} -- Setting a range of keys: {{domxref("IDBKeyRange")}} -- Retrieving and making changes to your data: {{domxref("IDBObjectStore")}} -- Using cursors: {{domxref("IDBCursor")}} -- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)). diff --git a/files/en-us/web/api/idbobjectstore/createindex/index.md b/files/en-us/web/api/idbobjectstore/createindex/index.md index e546a917b82911c..ef207bb539dc15a 100644 --- a/files/en-us/web/api/idbobjectstore/createindex/index.md +++ b/files/en-us/web/api/idbobjectstore/createindex/index.md @@ -32,12 +32,9 @@ createIndex(indexName, keyPath, options) ### Parameters - `indexName` - - : The name of the index to create. Note that it is possible to create an index with an - empty name. + - : The name of the index to create. Note that it is possible to create an index with an empty name. - `keyPath` - - : The key path for the index to use. Note that it is possible to create an index with - an empty `keyPath`, and also to pass in a sequence (array) as a - `keyPath`. + - : The key path for the index to use. Note that it is possible to create an index with an empty `keyPath`, and also to pass in a sequence (array) as a `keyPath`. - `options` {{optional_inline}} - : An object which can include the following @@ -47,8 +44,8 @@ createIndex(indexName, keyPath, options) - `multiEntry` - : If `true`, the index will add an entry in the index for each array element when the `keyPath` resolves to an array. If `false`, it will add one single entry containing the array. Defaults to `false`. - - `locale` {{non-standard_inline}} - - : Currently Firefox-only (43+), this allows you to specify a locale for the index. + - `locale` {{non-standard_inline}} {{deprecated_inline}} + - : Allows you to specify a locale for the index. Any sorting operations performed on the data via key ranges will then obey sorting rules of that locale (see [locale-aware sorting](/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB#locale-aware_sorting)). You can specify its value in one of three ways: diff --git a/files/en-us/web/api/idbtransaction/mode/index.md b/files/en-us/web/api/idbtransaction/mode/index.md index addf6e959ae7bf2..7ca25f62831eed7 100644 --- a/files/en-us/web/api/idbtransaction/mode/index.md +++ b/files/en-us/web/api/idbtransaction/mode/index.md @@ -28,10 +28,9 @@ The following values are available: - `readwrite` - : Allows reading and writing of data in existing data stores to be changed. - `versionchange` - - : Allows any operation to be performed, including ones that delete and + - : Allows any operation, including ones that delete and create object stores and indexes. - This mode is for updating the version number of transactions - that were started using {{domxref("IDBDatabase.setVersion()")}}. + This mode is for updating the version number of transactions if the need is detected when calling {{domxref("IDBFactory.open()")}}. Transactions of this mode cannot run concurrently with other transactions. Transactions in this mode are known as _upgrade transactions_. diff --git a/files/en-us/web/api/identitycredential/index.md b/files/en-us/web/api/identitycredential/index.md index 63dae1ec0a49359..72d14511a244557 100644 --- a/files/en-us/web/api/identitycredential/index.md +++ b/files/en-us/web/api/identitycredential/index.md @@ -7,7 +7,7 @@ status: browser-compat: api.IdentityCredential --- -{{APIRef("FedCM API")}}{{SeeCompatTable}} +{{APIRef("FedCM API")}}{{SeeCompatTable}}{{SecureContext_Header}} The **`IdentityCredential`** interface of the [Federated Credential Management API (FedCM)](/en-US/docs/Web/API/FedCM_API) represents a user identity credential arising from a successful federated sign-in. @@ -19,8 +19,10 @@ A successful {{domxref("CredentialsContainer.get", "navigator.credentials.get()" _Inherits properties from its ancestor, {{domxref("Credential")}}._ +- {{domxref("IdentityCredential.isAutoSelected")}} {{ReadOnlyInline}} {{experimental_inline}} + - : A boolean value that indicates whether the federated sign-in was carried out using [auto-reauthentication](/en-US/docs/Web/API/FedCM_API/RP_sign-in#auto-reauthentication) (i.e. without user mediation) or not. - {{domxref("IdentityCredential.token")}} {{experimental_inline}} - - : Returns a {{jsxref("Promise")}} that resolves with the {{domxref("Credential")}} instance that matches the provided parameters. + - : Returns the token used to validate the associated sign-in. ## Examples @@ -48,7 +50,7 @@ If successful, this call will fulfill with an `IdentityCredential` instance. Fro console.log(identityCredential.token); ``` -Check out [Federated Credential Management API (FedCM)](/en-US/docs/Web/API/FedCM_API) for more details on how this works. This call will start off the sign-in flow described in [FedCM sign-in flow](/en-US/docs/Web/API/FedCM_API#fedcm_sign-in_flow). +Check out [Federated Credential Management API (FedCM)](/en-US/docs/Web/API/FedCM_API) for more details on how this works. This call will start off the sign-in flow described in [FedCM sign-in flow](/en-US/docs/Web/API/FedCM_API/RP_sign-in#fedcm_sign-in_flow). ## Specifications diff --git a/files/en-us/web/api/identitycredential/isautoselected/index.md b/files/en-us/web/api/identitycredential/isautoselected/index.md new file mode 100644 index 000000000000000..0dd61b5a3dec234 --- /dev/null +++ b/files/en-us/web/api/identitycredential/isautoselected/index.md @@ -0,0 +1,56 @@ +--- +title: "IdentityCredential: isAutoSelected property" +short-title: isAutoSelected +slug: Web/API/IdentityCredential/isAutoSelected +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.IdentityCredential.isAutoSelected +--- + +{{securecontext_header}}{{APIRef("FedCM API")}}{{SeeCompatTable}} + +The **`isAutoSelected`** read-only property of the {{domxref("IdentityCredential")}} interface indicates whether the federated sign-in flow was carried out using [auto-reauthentication](/en-US/docs/Web/API/FedCM_API/RP_sign-in#auto-reauthentication) (i.e. without user mediation) or not. + +Automatic reauthentication can occur when a {{domxref("CredentialsContainer.get", "navigator.credentials.get()")}} call is issued with a [`mediation`](/en-US/docs/Web/API/CredentialsContainer/get#mediation) option value of `"optional"` or `"silent"`. It is useful for a relying party (RP) to know whether auto reauthentication occurred for analytics/performance evaluation and for UX purposes — automatic sign-in may warrant a different UI flow to non-automatic sign-in. + +## Value + +A boolean value. `true` indicates that automatic reauthentication was used; `false` indicates that it was not. + +## Examples + +RPs can call `navigator.credentials.get()` with the `identity` option to make a request for users to sign in to the RP via an identity provider (IdP), using identity federation. Auto-reauthentication behavior is controlled by the [`mediation`](/en-US/docs/Web/API/CredentialsContainer/get#mediation) option in the `get()` call: + +```js +async function signIn() { + const identityCredential = await navigator.credentials.get({ + identity: { + providers: [ + { + configURL: "https://accounts.idp.example/config.json", + clientId: "********", + }, + ], + }, + mediation: "optional", // this is the default + }); + + // isAutoSelected is true if auto-reauthentication occurred. + const isAutoSelected = identityCredential.isAutoSelected; +} +``` + +Check out [Federated Credential Management API (FedCM)](/en-US/docs/Web/API/FedCM_API) for more details on how this works. This call will start off the sign-in flow described in [FedCM sign-in flow](/en-US/docs/Web/API/FedCM_API/RP_sign-in#fedcm_sign-in_flow). + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- [Federated Credential Management API](https://developer.chrome.com/docs/privacy-sandbox/fedcm/) diff --git a/files/en-us/web/api/identitycredential/token/index.md b/files/en-us/web/api/identitycredential/token/index.md index ff2d96ec790306b..c66b8488b748bac 100644 --- a/files/en-us/web/api/identitycredential/token/index.md +++ b/files/en-us/web/api/identitycredential/token/index.md @@ -8,10 +8,18 @@ status: browser-compat: api.IdentityCredential.token --- -{{APIRef("FedCM API")}}{{SeeCompatTable}} +{{APIRef("FedCM API")}}{{SeeCompatTable}}{{SecureContext_Header}} The **`token`** read-only property of the {{domxref("IdentityCredential")}} interface returns the token used to validate the associated sign-in. +The token includes user identity information that has been signed with the identity provider (IdP)'s {{glossary("digital certificate")}}. + +The relying party (RP) sends the token to its server to validate the certificate, and on success can use the (now trusted) identity information in the token to sign them into their service (starting a new session), sign them up to their service if they are a new user, etc. + +If the user has never signed into the IdP or is logged out, the associated {{domxref("CredentialsContainer.get", "get()")}} call rejects with an error and the RP can direct the user to the IdP login page to sign in or create an account. + +> **Note:** The exact structure and content of the validation token token is opaque to the FedCM API, and to the browser. The IdP decides on the syntax and usage of it, and the RP needs to follow the instructions provided by the IdP (see [Verify the Google ID token on your server side](https://developers.google.com/identity/gsi/web/guides/verify-google-id-token), for example) to make sure they are using it correctly. + ## Value A string. @@ -40,7 +48,7 @@ async function signIn() { A successful {{domxref("CredentialsContainer.get", "navigator.credentials.get()")}} call that includes an `identity` option fulfills with an `IdentityCredential` instance, which can be used to access the token used to validate the sign-in. -Check out [Federated Credential Management API (FedCM)](/en-US/docs/Web/API/FedCM_API) for more details on how this works. This call will start off the sign-in flow described in [FedCM sign-in flow](/en-US/docs/Web/API/FedCM_API#fedcm_sign-in_flow). +Check out [Federated Credential Management API (FedCM)](/en-US/docs/Web/API/FedCM_API) for more details on how this works. This call will start off the sign-in flow described in [FedCM sign-in flow](/en-US/docs/Web/API/FedCM_API/RP_sign-in#fedcm_sign-in_flow). ## Specifications diff --git a/files/en-us/web/api/identityprovider/close_static/index.md b/files/en-us/web/api/identityprovider/close_static/index.md new file mode 100644 index 000000000000000..cee69083ce7feb9 --- /dev/null +++ b/files/en-us/web/api/identityprovider/close_static/index.md @@ -0,0 +1,51 @@ +--- +title: "IdentityProvider: close() static method" +short-title: close() +slug: Web/API/IdentityProvider/close_static +page-type: web-api-static-method +status: + - experimental +browser-compat: api.IdentityProvider.close_static +--- + +{{securecontext_header}}{{APIRef("FedCM API")}}{{SeeCompatTable}} + +The **`close()`** static method of the {{domxref("IdentityProvider")}} interface provides a manual signal to the browser that an IdP sign-in flow is finished. + +## Usage notes + +`close()` needs to be called from the same origin as the IdP sign-in dialog, as defined in the [IdP config](/en-US/docs/Web/API/FedCM_API/IDP_integration#provide_a_config_file_and_endpoints). + +`close()` is needed to close the IdP sign-in dialog when sign-in is completely finished and the IdP has finished collecting data from the user. A primary use case for `close()` is closing the IdP sign-in dialog in cases where [the browser and the IdP login status become out of sync](/en-US/docs/Web/API/FedCM_API/IDP_integration#what_if_the_browser_and_the_idp_login_status_become_out_of_sync), and the browser initiates a dynamic sign-in flow to correct the issue. + +## Syntax + +```js-nolint +IdentityProvider.close() +``` + +### Parameters + +None. + +### Return value + +`undefined`. + +## Examples + +```js +IdentityProvider.close(); +``` + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See also + +- [Federated Credential Management API](https://developer.chrome.com/docs/privacy-sandbox/fedcm/) on developer.chrome.com (2023) diff --git a/files/en-us/web/api/identityprovider/getuserinfo_static/index.md b/files/en-us/web/api/identityprovider/getuserinfo_static/index.md index c8d294d1ecf0eda..241a81dad545814 100644 --- a/files/en-us/web/api/identityprovider/getuserinfo_static/index.md +++ b/files/en-us/web/api/identityprovider/getuserinfo_static/index.md @@ -8,15 +8,15 @@ status: browser-compat: api.IdentityProvider.getUserInfo_static --- -{{APIRef("FedCM API")}}{{SeeCompatTable}} +{{APIRef("FedCM API")}}{{SeeCompatTable}}{{SecureContext_Header}} -The **`getUserInfo()`** static method of the {{domxref("IdentityProvider")}} interface returns information about a previously signed in user, which can be used to provide a personalized welcome message and sign-in button. This method has to be called from within an identity provider (IdP)-origin {{htmlelement("iframe")}} so that RP scripts cannot access the data. This must occur after a previously signed in user returns to the relying party (RP) site. +The **`getUserInfo()`** static method of the {{domxref("IdentityProvider")}} interface returns information about a user that has signed in, which can be used to provide a personalized welcome message and sign-in button. This method has to be called from within an identity provider (IdP)-origin {{htmlelement("iframe")}} so that RP scripts cannot access the data. This must occur after a user has been signed in to a relying party (RP) site. This pattern is already common on sites that use identity federation for sign-in, but `getUserInfo()` provides a way to achieve it without relying on third-party cookies. ## Usage notes -When `getUserInfo()` is called, the browser will make a request to the IdP [accounts list endpoint](/en-US/docs/Web/API/FedCM_API#the_accounts_list_endpoint) for the user information only when both the below conditions are true: +When `getUserInfo()` is called, the browser will make a request to the IdP [accounts list endpoint](/en-US/docs/Web/API/FedCM_API/IDP_integration#the_accounts_list_endpoint) for the user information only when both the conditions below are true: - The user has previously signed in to the RP with the IdP via FedCM on the same browser instance, and the data hasn't been cleared. - The user is signed in to the IdP on the same browser instance. @@ -40,7 +40,7 @@ IdentityProvider.getUserInfo(config) - `config` - : A configuration object, which can contain the following properties: - `configURL` - - : The URL of the [configuration file](/en-US/docs/Web/API/FedCM_API#provide_a_config_file) for the identity provider from which you want to get user information. + - : The URL of the [configuration file](/en-US/docs/Web/API/FedCM_API/IDP_integration#provide_a_config_file_and_endpoints) for the identity provider from which you want to get user information. - `clientId` - : The RP's client identifier issued by the IdP. diff --git a/files/en-us/web/api/identityprovider/index.md b/files/en-us/web/api/identityprovider/index.md index 995e3f35ae71a9a..c266f39100f58d3 100644 --- a/files/en-us/web/api/identityprovider/index.md +++ b/files/en-us/web/api/identityprovider/index.md @@ -7,14 +7,16 @@ status: browser-compat: api.IdentityProvider --- -{{APIRef("FedCM API")}}{{SeeCompatTable}} +{{APIRef("FedCM API")}}{{SeeCompatTable}}{{SecureContext_Header}} -The **`IdentityProvider`** interface of the [Federated Credential Management (FedCM) API](/en-US/docs/Web/API/FedCM_API) represents an identity provider (IdP) and provides access to related information. +The **`IdentityProvider`** interface of the [Federated Credential Management (FedCM) API](/en-US/docs/Web/API/FedCM_API) represents an identity provider (IdP) and provides access to related information and functionality. {{InheritanceDiagram}} ## Static methods +- {{domxref("IdentityProvider.close_static", "close()")}} {{experimental_inline}} + - : Provides a manual signal to the browser that an IdP sign-in flow is finished. This is needed to, for example, close the IdP sign-in dialog when sign-in is completely finished and the IdP has finished colecting data from the user. - {{domxref("IdentityProvider.getUserInfo_static", "getUserInfo()")}} {{experimental_inline}} - : Returns information about a previously signed in user on their return to an IdP, which can be used to provide a personalized welcome message and sign-in button. @@ -39,7 +41,7 @@ if (user_info.length > 0) { // ... - // Render the personalized sign-in button using the information returned above + // Render a personalized sign-in button using the information returned above } ``` diff --git a/files/en-us/web/api/imagecapture/getphotocapabilities/index.md b/files/en-us/web/api/imagecapture/getphotocapabilities/index.md index 44015e38eb90803..d96bc0d20e71535 100644 --- a/files/en-us/web/api/imagecapture/getphotocapabilities/index.md +++ b/files/en-us/web/api/imagecapture/getphotocapabilities/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.ImageCapture.getPhotoCapabilities --- -{{APIRef("MediaStream Image")}}{{SeeCompatTable}} +{{APIRef("Image Capture API")}}{{SeeCompatTable}} The **`getPhotoCapabilities()`** method of the {{domxref("ImageCapture")}} interface returns a {{jsxref("Promise")}} @@ -38,6 +38,13 @@ A {{jsxref("Promise")}} that resolves with an object containing the following pr - `fillLightMode` - : Returns an array of available fill light options. Options include `auto`, `off`, or `flash`. +### Exceptions + +- `InvalidStateError` {{domxref("DOMException")}} + - : Thrown if `readyState` property of the `MediaStreamTrack` passing in the constructor is not `live`. +- `OperationError` {{domxref("DOMException")}} + - : Thrown if the operation can't complete for any reason. + ## Examples The following example, extracted from [Chrome's Image Capture / Photo Resolution Sample](https://googlechrome.github.io/samples/image-capture/photo-resolution.html), uses the results from diff --git a/files/en-us/web/api/imagecapture/getphotosettings/index.md b/files/en-us/web/api/imagecapture/getphotosettings/index.md index 1b4e92fc353ea73..b926b8de436aae9 100644 --- a/files/en-us/web/api/imagecapture/getphotosettings/index.md +++ b/files/en-us/web/api/imagecapture/getphotosettings/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.ImageCapture.getPhotoSettings --- -{{APIRef("MediaStream Image")}}{{SeeCompatTable}} +{{APIRef("Image Capture API")}}{{SeeCompatTable}} The **`getPhotoSettings()`** method of the {{domxref("ImageCapture")}} interface returns a {{jsxref("Promise")}} that @@ -27,11 +27,10 @@ None. ### Return value -A {{jsxref("Promise")}} that resolves with an object -containing the following properties: +A {{jsxref("Promise")}} that resolves with an object containing the following properties: - `fillLightMode` - - : The flash setting of the capture device, one of `"auto"`, `"off"`, or `"on"`. + - : The flash setting of the capture device, one of `"auto"`, `"off"`, or `"flash"`. - `imageHeight` - : The desired image height as an integer. The browser selects the closest width value to this setting if it only supports discrete heights. - `imageWidth` @@ -39,6 +38,13 @@ containing the following properties: - `redEyeReduction` - : A boolean indicating whether the red-eye reduction should be used if it is available. +### Exceptions + +- `InvalidStateError` {{domxref("DOMException")}} + - : Thrown if `readyState` property of the `MediaStreamTrack` passing in the constructor is not `live`. +- `OperationError` {{domxref("DOMException")}} + - : Thrown if the operation can't complete for any reason. + ## Examples The following example, extracted from [Chrome's Image Capture / Photo Resolution Sample](https://googlechrome.github.io/samples/image-capture/photo-resolution.html), uses the results from diff --git a/files/en-us/web/api/imagecapture/grabframe/index.md b/files/en-us/web/api/imagecapture/grabframe/index.md index 49c7071ed22b240..c8df80c8d9a39e0 100644 --- a/files/en-us/web/api/imagecapture/grabframe/index.md +++ b/files/en-us/web/api/imagecapture/grabframe/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.ImageCapture.grabFrame --- -{{APIRef("MediaStream Image")}}{{SeeCompatTable}} +{{APIRef("Image Capture API")}}{{SeeCompatTable}} The **`grabFrame()`** method of the {{domxref("ImageCapture")}} interface takes a snapshot of the live video in a @@ -29,6 +29,13 @@ None. A {{jsxref("Promise")}} that resolves to an {{domxref("ImageBitmap")}} object. +### Exceptions + +- `InvalidStateError` {{domxref("DOMException")}} + - : Thrown if `readyState` property of the `MediaStreamTrack` passing in the constructor is not `live`. +- `UnknownError` {{domxref("DOMException")}} + - : Thrown if the operation can't complete for any reason. + ## Examples This example is extracted from this [Simple Image Capture demo](https://simpl.info/imagecapture/). It shows how to use the {{jsxref("Promise")}} returned by diff --git a/files/en-us/web/api/imagecapture/imagecapture/index.md b/files/en-us/web/api/imagecapture/imagecapture/index.md index db7029dcb4e2b97..f012139dffd18a9 100644 --- a/files/en-us/web/api/imagecapture/imagecapture/index.md +++ b/files/en-us/web/api/imagecapture/imagecapture/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.ImageCapture.ImageCapture --- -{{APIRef("MediaStream Image")}}{{SeeCompatTable}} +{{APIRef("Image Capture API")}}{{SeeCompatTable}} The **`ImageCapture()`** constructor creates a new {{domxref("ImageCapture")}} object. @@ -31,6 +31,11 @@ new ImageCapture(videoTrack) A new `ImageCapture` object which can be used to capture still frames from the specified video track. +### Exceptions + +- `NotSupportedError` {{domxref("DOMException")}} + - : Thrown if the `videoTrack` parameter's `kind` property is not `video`. + ## Examples The following example shows how to use a call to diff --git a/files/en-us/web/api/imagecapture/index.md b/files/en-us/web/api/imagecapture/index.md index 278c127d32a7587..d22026791b2c61c 100644 --- a/files/en-us/web/api/imagecapture/index.md +++ b/files/en-us/web/api/imagecapture/index.md @@ -7,7 +7,7 @@ status: browser-compat: api.ImageCapture --- -{{APIRef("MediaStream Image")}}{{SeeCompatTable}} +{{APIRef("Image Capture API")}}{{SeeCompatTable}} The **`ImageCapture`** interface of the [MediaStream Image Capture API](/en-US/docs/Web/API/MediaStream_Image_Capture_API) provides methods to enable the capture of images or photos from a camera or other photographic device. It provides an interface for capturing images from a photographic device referenced through a valid {{domxref("MediaStreamTrack")}}. @@ -23,12 +23,10 @@ The **`ImageCapture`** interface of the [MediaStream Image Capture API](/en-US/d ## Instance methods -The `ImageCapture` interface is based on {{domxref("EventTarget")}}, so it includes the methods defined by that interface as well as the ones listed below. - - {{domxref("ImageCapture.takePhoto()")}} {{Experimental_Inline}} - : Takes a single exposure using the video capture device sourcing a {{domxref("MediaStreamTrack")}} and returns a {{jsxref("Promise")}} that resolves with a {{domxref("Blob")}} containing the data. - {{domxref("ImageCapture.getPhotoCapabilities()")}} {{Experimental_Inline}} - - : Returns a {{jsxref("Promise")}} that resolves with a `PhotoCapabilities` object containing the ranges of available configuration options. + - : Returns a {{jsxref("Promise")}} that resolves with an object containing the ranges of available configuration options. - {{domxref("ImageCapture.getPhotoSettings()")}} {{Experimental_Inline}} - : Returns a {{jsxref("Promise")}} that resolves with an object containing the current photo configuration settings. - {{domxref("ImageCapture.grabFrame()")}} {{Experimental_Inline}} diff --git a/files/en-us/web/api/imagecapture/takephoto/index.md b/files/en-us/web/api/imagecapture/takephoto/index.md index cc1e508cbabae1d..8a7a7ade897e5bd 100644 --- a/files/en-us/web/api/imagecapture/takephoto/index.md +++ b/files/en-us/web/api/imagecapture/takephoto/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.ImageCapture.takePhoto --- -{{APIRef("MediaStream Image")}}{{SeeCompatTable}} +{{APIRef("Image Capture API")}}{{SeeCompatTable}} The **`takePhoto()`** method of the {{domxref("ImageCapture")}} interface takes a single exposure using the video capture @@ -47,6 +47,13 @@ takePhoto(photoSettings) A {{jsxref("Promise")}} that resolves with a {{domxref("Blob")}}. +### Exceptions + +- `InvalidStateError` {{domxref("DOMException")}} + - : Thrown if `readyState` property of the `MediaStreamTrack` passing in the constructor is not `live`. +- `UnknownError` {{domxref("DOMException")}} + - : Thrown if the operation can't complete for any reason. + ## Examples This example is extracted from this [Simple Image Capture demo](https://simpl.info/imagecapture/). It shows how to use the {{jsxref("Promise")}} returned by diff --git a/files/en-us/web/api/imagecapture/track/index.md b/files/en-us/web/api/imagecapture/track/index.md index 055982247adc8b6..3afea26d99476fd 100644 --- a/files/en-us/web/api/imagecapture/track/index.md +++ b/files/en-us/web/api/imagecapture/track/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.ImageCapture.track --- -{{APIRef("MediaStream Image")}}{{SeeCompatTable}} +{{APIRef("Image Capture API")}}{{SeeCompatTable}} The **`track`** read-only property of the {{domxref("ImageCapture")}} interface returns a reference to the diff --git a/files/en-us/web/api/imagedecoder/imagedecoder/index.md b/files/en-us/web/api/imagedecoder/imagedecoder/index.md index bc9d9291980ed68..6aaa03641888b93 100644 --- a/files/en-us/web/api/imagedecoder/imagedecoder/index.md +++ b/files/en-us/web/api/imagedecoder/imagedecoder/index.md @@ -41,6 +41,8 @@ new ImageDecoder(init) - : An integer indicating the desired height for the decoded output. Has no effect unless the image codec supports variable resolution decoding. - `preferAnimation` {{optional_inline}} - : A {{jsxref("Boolean")}} indicating whether the initial track selection should prefer an animated track. + - `transfer` + - : An array of {{jsxref("ArrayBuffer")}}s that `ImageDecoder` will detach and take ownership of. If the array contains the {{jsxref("ArrayBuffer")}} backing `data`, `ImageDecoder` will use that buffer directly instead of copying from it. ## Examples diff --git a/files/en-us/web/api/indexeddb_api/index.md b/files/en-us/web/api/indexeddb_api/index.md index ac8a436db09b0fb..5f1f4ff2d6453ab 100644 --- a/files/en-us/web/api/indexeddb_api/index.md +++ b/files/en-us/web/api/indexeddb_api/index.md @@ -13,7 +13,7 @@ IndexedDB is a low-level API for client-side storage of significant amounts of s ## Key concepts and usage -IndexedDB is a transactional database system, like an SQL-based RDBMS. However, unlike SQL-based RDBMSes, which use fixed-column tables, IndexedDB is a JavaScript-based object-oriented database. IndexedDB lets you store and retrieve objects that are indexed with a **key**; any objects supported by the [structured clone algorithm](/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm) can be stored. You need to specify the database schema, open a connection to your database, and then retrieve and update data within a series of **transactions**. +IndexedDB is a transactional database system, like an SQL-based Relational Database Management System (RDBMS). However, unlike SQL-based RDBMSes, which use fixed-column tables, IndexedDB is a JavaScript-based object-oriented database. IndexedDB lets you store and retrieve objects that are indexed with a **key**; any objects supported by the [structured clone algorithm](/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm) can be stored. You need to specify the database schema, open a connection to your database, and then retrieve and update data within a series of **transactions**. - Read more about [IndexedDB key characteristics and basic terminology](/en-US/docs/Web/API/IndexedDB_API/Basic_Terminology). - Learn to use IndexedDB asynchronously from first principles with our [Using IndexedDB](/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB) guide. @@ -30,7 +30,7 @@ There are a number of web technologies that store data of one kind or another on ## Interfaces -To get access to a database, call [`open()`](/en-US/docs/Web/API/IDBFactory/open) on the [`indexedDB`](/en-US/docs/Web/API/indexedDB) attribute of a [window](/en-US/docs/Web/API/Window) object. This method returns an {{domxref("IDBRequest")}} object; asynchronous operations communicate to the calling application by firing events on {{domxref("IDBRequest")}} objects. +To get access to a database, call [`open()`](/en-US/docs/Web/API/IDBFactory/open) on the [`indexedDB`](/en-US/docs/Web/API/indexedDB) property of a [window](/en-US/docs/Web/API/Window) object. This method returns an {{domxref("IDBRequest")}} object; asynchronous operations communicate to the calling application by firing events on {{domxref("IDBRequest")}} objects. ### Connecting to a database @@ -57,8 +57,6 @@ To get access to a database, call [`open()`](/en-US/docs/Web/API/IDBFactory/open - : Iterates over object stores and indexes and returns the cursor's current value. - {{domxref("IDBKeyRange")}} - : Defines a key range that can be used to retrieve data from a database in a certain range. -- {{domxref("IDBLocaleAwareKeyRange")}} {{Non-standard_inline}} - - : Defines a key range that can be used to retrieve data from a database in a certain range, sorted according to the rules of the locale specified for a certain index (see the [`options`](/en-US/docs/Web/API/IDBObjectStore/createIndex#options) parameter to [`IDBObjectStore.createIndex()`](/en-US/docs/Web/API/IDBObjectStore/createIndex).) This interface isn't part of the 2.0 specification. ### Custom event interfaces diff --git a/files/en-us/web/api/indexeddb_api/using_indexeddb/index.md b/files/en-us/web/api/indexeddb_api/using_indexeddb/index.md index a7c1e4c1c8ecdc6..44bc2d076118514 100644 --- a/files/en-us/web/api/indexeddb_api/using_indexeddb/index.md +++ b/files/en-us/web/api/indexeddb_api/using_indexeddb/index.md @@ -624,23 +624,6 @@ In fact, there is no way to guarantee that IndexedDB transactions will complete, At least with the addition of the abort notifications and {{domxref("IDBDatabase.close_event", "IDBDatabase.onclose")}}, you can know when this has happened. -## Locale-aware sorting - -Mozilla has implemented the ability to perform locale-aware sorting of IndexedDB data in Firefox 43+. By default, IndexedDB didn't handle internationalization of sorting strings at all, and everything was sorted as if it were English text. For example, b, á, z, a would be sorted as: - -- a -- b -- z -- á - -which is obviously not how users want their data to be sorted — Aaron and Áaron for example should go next to one another in a contacts list. Achieving proper international sorting therefore required the entire dataset to be called into memory, and sorting to be performed by client-side JavaScript, which is not very efficient. - -This new functionality enables developers to specify a locale when creating an index using {{domxref("IDBObjectStore.createIndex()")}} (check out its parameters.) In such cases, when a cursor is then used to iterate through the dataset, and you want to specify locale-aware sorting, you can use a specialized {{domxref("IDBLocaleAwareKeyRange")}}. - -{{domxref("IDBIndex")}} has also had new properties added to it to specify if it has a locale specified, and what it is: `locale` (returns the locale if any, or null if none is specified) and `isAutoLocale` (returns `true` if the index was created with an auto locale, meaning that the platform's default locale is used, `false` otherwise.) - -> **Note:** This feature is currently hidden behind a flag — to enable it and experiment, go to `about:config` and enable `dom.indexedDB.experimental`. - ## Full IndexedDB example We have a complete example using the IndexedDB API. The example uses IndexedDB to store and retrieve publications. diff --git a/files/en-us/web/api/ink_api/index.md b/files/en-us/web/api/ink_api/index.md index 37de7c9be251a92..365d0d5721a7f64 100644 --- a/files/en-us/web/api/ink_api/index.md +++ b/files/en-us/web/api/ink_api/index.md @@ -59,7 +59,7 @@ The result is that a delegated ink trail is drawn ahead of the default browser r ```css div { - background-color: rgba(0, 255, 0, 1); + background-color: rgb(0 255 0 / 100%); position: fixed; top: 1rem; left: 1rem; @@ -72,7 +72,7 @@ div { const ctx = canvas.getContext("2d"); const presenter = navigator.ink.requestPresenter({ presentationArea: canvas }); let move_cnt = 0; -let style = { color: "rgba(0, 255, 0, 1)", diameter: 10 }; +let style = { color: "rgb(0 255 0 / 100%)", diameter: 10 }; function getRandomInt(min, max) { min = Math.ceil(min); @@ -89,10 +89,10 @@ canvas.addEventListener("pointermove", async (evt) => { const g = getRandomInt(0, 255); const b = getRandomInt(0, 255); - style = { color: `rgba(${r}, ${g}, ${b}, 1)`, diameter: 10 }; + style = { color: `rgb(${r} ${g} ${b} / 100%)`, diameter: 10 }; move_cnt = 0; document.getElementById("div").style.backgroundColor = - `rgba(${r}, ${g}, ${b}, 0.6)`; + `rgb(${r} ${g} ${b} / 60%)`; } move_cnt += 1; await presenter.updateInkTrailStartPoint(evt, style); diff --git a/files/en-us/web/api/inkpresenter/index.md b/files/en-us/web/api/inkpresenter/index.md index c742b1531ff3423..a42632e70ba3b4e 100644 --- a/files/en-us/web/api/inkpresenter/index.md +++ b/files/en-us/web/api/inkpresenter/index.md @@ -40,7 +40,7 @@ The result is that a delegated ink trail is drawn ahead of the default browser r const ctx = canvas.getContext("2d"); let presenter = navigator.ink.requestPresenter({ presentationArea: canvas }); let move_cnt = 0; -let style = { color: "rgba(0, 0, 255, 1)", diameter: 10 }; +let style = { color: "rgb(0 0 255 / 100%)", diameter: 10 }; function getRandomInt(min, max) { min = Math.ceil(min); @@ -56,10 +56,13 @@ canvas.addEventListener("pointermove", (evt) => { let r = getRandomInt(0, 255); let g = getRandomInt(0, 255); let b = getRandomInt(0, 255); - style = { color: "rgba(" + r + ", " + g + ", " + b + ", 1)", diameter: 10 }; + style = { + color: "rgb(" + r + " " + g + " " + b + " / 100%)", + diameter: 10, + }; move_cnt = 0; document.getElementById("div").style.backgroundColor = - "rgba(" + r + ", " + g + ", " + b + ", 1)"; + "rgb(" + r + " " + g + " " + b + " / 100%)"; } move_cnt += 1; presenter.then(function (v) { diff --git a/files/en-us/web/api/inkpresenter/updateinktrailstartpoint/index.md b/files/en-us/web/api/inkpresenter/updateinktrailstartpoint/index.md index 957beae5ac5bd9b..fce80d36c70dce6 100644 --- a/files/en-us/web/api/inkpresenter/updateinktrailstartpoint/index.md +++ b/files/en-us/web/api/inkpresenter/updateinktrailstartpoint/index.md @@ -65,7 +65,7 @@ The result is that a delegated ink trail is drawn ahead of the default browser r ```css div { - background-color: rgba(0, 255, 0, 1); + background-color: rgb(0 255 0 / 100%); position: fixed; top: 1rem; left: 1rem; @@ -78,7 +78,7 @@ div { const ctx = canvas.getContext("2d"); const presenter = navigator.ink.requestPresenter({ presentationArea: canvas }); let move_cnt = 0; -let style = { color: "rgba(0, 255, 0, 1)", diameter: 10 }; +let style = { color: "rgb(0 255 0 / 100%)", diameter: 10 }; function getRandomInt(min, max) { min = Math.ceil(min); @@ -95,10 +95,10 @@ canvas.addEventListener("pointermove", async (evt) => { const g = getRandomInt(0, 255); const b = getRandomInt(0, 255); - style = { color: `rgba(${r}, ${g}, ${b}, 1)`, diameter: 10 }; + style = { color: `rgb(${r} ${g} ${b} / 100%)`, diameter: 10 }; move_cnt = 0; document.getElementById("div").style.backgroundColor = - `rgba(${r}, ${g}, ${b}, 0.6)`; + `rgb(${r} ${g} ${b} / 60%)`; } move_cnt += 1; await presenter.updateInkTrailStartPoint(evt, style); diff --git a/files/en-us/web/api/inputdeviceinfo/getcapabilities/index.md b/files/en-us/web/api/inputdeviceinfo/getcapabilities/index.md index 3dc3d80b2ebeacb..18b38c704c5d93b 100644 --- a/files/en-us/web/api/inputdeviceinfo/getcapabilities/index.md +++ b/files/en-us/web/api/inputdeviceinfo/getcapabilities/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.InputDeviceInfo.getCapabilities --- -{{APIRef("Media Capture and Streams")}} +{{APIRef("Media Capture and Streams")}}{{securecontext_header}} The **`getCapabilities()`** method of the {{domxref("InputDeviceInfo")}} interface returns a `MediaTrackCapabilities` object describing the primary audio or video track of the device's {{domxref("MediaStream")}}. @@ -22,13 +22,13 @@ None. ### Return value -A `MediaTrackCapabilities` object containing the following members: +A `MediaTrackCapabilities` object which specifies the value or range of values which are supported for each of the user agent's supported constrainable properties, containing the following members: - `deviceId` - : A [`ConstrainDOMString`](/en-US/docs/Web/API/MediaTrackConstraints#constraindomstring) object containing the device ID. - `groupId` - : A [`ConstrainDOMString`](/en-US/docs/Web/API/MediaTrackConstraints#constraindomstring) object containing a group ID. -- `autoGainControl`> +- `autoGainControl` - : A [`ConstrainBoolean`](/en-US/docs/Web/API/MediaTrackConstraints#constrainboolean) object reporting if the source can do auto gain control. If the feature can be controlled by a script the source will report both true and false as possible values. - `channelCount` @@ -84,3 +84,7 @@ navigator.mediaDevices.enumerateDevices().then((devices) => { ## Browser compatibility {{Compat}} + +## See also + +- {{domxref("MediaStreamTrack.getCapabilities()")}}, which also return a `MediaTrackCapabilities` object. diff --git a/files/en-us/web/api/inputdeviceinfo/index.md b/files/en-us/web/api/inputdeviceinfo/index.md index 725f5c60ebfdd2c..d2815a474ae4239 100644 --- a/files/en-us/web/api/inputdeviceinfo/index.md +++ b/files/en-us/web/api/inputdeviceinfo/index.md @@ -5,16 +5,22 @@ page-type: web-api-interface browser-compat: api.InputDeviceInfo --- -{{APIRef("Media Capture and Streams")}} +{{APIRef("Media Capture and Streams")}}{{securecontext_header}} -The **`InputDeviceInfo`** interface of the {{domxref('Media Capture and Streams API','','',' ')}} gives access to the capabilities of the input device that it represents. +The **`InputDeviceInfo`** interface of the {{domxref("Media Capture and Streams API", "", "", "nocode")}} gives access to the capabilities of the input device that it represents. `InputDeviceInfo` objects are returned by {{domxref("MediaDevices.enumerateDevices()")}} if the returned device is an audio or video input device. {{InheritanceDiagram}} +## Instance properties + +_Also inherits properties from its parent interface, {{DOMxRef("MediaDeviceInfo")}}._ + ## Instance methods +_Also inherits methods from its parent interface, {{DOMxRef("MediaDeviceInfo")}}._ + - {{domxref("InputDeviceInfo.getCapabilities()")}} - : Returns a `MediaTrackCapabilities` object describing the primary audio or video track of a device's `MediaStream`. diff --git a/files/en-us/web/api/inputevent/data/index.md b/files/en-us/web/api/inputevent/data/index.md index 3b2b0c2c3c87758..41ad1b48bb771c3 100644 --- a/files/en-us/web/api/inputevent/data/index.md +++ b/files/en-us/web/api/inputevent/data/index.md @@ -19,7 +19,7 @@ A string. ## Examples -In the following example, an event listener receives the [input](/en-US/docs/Web/API/HTMLElement/input_event) event. Any textual change +In the following example, an event listener receives the [input](/en-US/docs/Web/API/Element/input_event) event. Any textual change to the {{htmlelement("input")}} element is retrieved by `InputEvent.data` and inserted into a paragraph using the [`Node.textContent`](/en-US/docs/Web/API/Node/textContent) diff --git a/files/en-us/web/api/inputevent/datatransfer/index.md b/files/en-us/web/api/inputevent/datatransfer/index.md index 01aec2fe5681c6f..98d5ff91abe76f0 100644 --- a/files/en-us/web/api/inputevent/datatransfer/index.md +++ b/files/en-us/web/api/inputevent/datatransfer/index.md @@ -19,7 +19,7 @@ A {{domxref("DataTransfer")}} object. ## Examples -In the following simple example we've set up an event listener on the [input](/en-US/docs/Web/API/HTMLElement/input_event) event so that when any +In the following simple example we've set up an event listener on the [input](/en-US/docs/Web/API/Element/input_event) event so that when any content is pasted into the contenteditable {{htmlelement("p")}} element, its HTML source is retrieved via the [`InputEvent.dataTransfer.getData()`](/en-US/docs/Web/API/DataTransfer/getData) diff --git a/files/en-us/web/api/inputevent/gettargetranges/index.md b/files/en-us/web/api/inputevent/gettargetranges/index.md index 8cfe5ae723ed2ec..d68bcd421397cfc 100644 --- a/files/en-us/web/api/inputevent/gettargetranges/index.md +++ b/files/en-us/web/api/inputevent/gettargetranges/index.md @@ -83,7 +83,7 @@ function isBeforeInputEventAvailable() { ### Basic usage The following example selects a `contenteditable` element and utilizes the -[`beforeinput`](/en-US/docs/Web/API/HTMLElement/beforeinput_event) +[`beforeinput`](/en-US/docs/Web/API/Element/beforeinput_event) event to log the result of `getTargetRanges()`. ```js diff --git a/files/en-us/web/api/inputevent/index.md b/files/en-us/web/api/inputevent/index.md index d28b06fa39d93d8..6310249ed0120b1 100644 --- a/files/en-us/web/api/inputevent/index.md +++ b/files/en-us/web/api/inputevent/index.md @@ -46,5 +46,5 @@ _This interface inherits methods from its parents, {{DOMxRef("UIEvent")}} and {{ ## See also -- [`beforeinput` event](/en-US/docs/Web/API/HTMLElement/beforeinput_event) -- [`input` event](/en-US/docs/Web/API/HTMLElement/input_event) +- [`beforeinput` event](/en-US/docs/Web/API/Element/beforeinput_event) +- [`input` event](/en-US/docs/Web/API/Element/input_event) diff --git a/files/en-us/web/api/inputevent/inputtype/index.md b/files/en-us/web/api/inputevent/inputtype/index.md index a82b456f3545f1f..fd5d167a35c3abd 100644 --- a/files/en-us/web/api/inputevent/inputtype/index.md +++ b/files/en-us/web/api/inputevent/inputtype/index.md @@ -17,11 +17,11 @@ Possible changes include for example inserting, deleting, and formatting text. A string containing the type of input that was made. There are many possible values, such as `insertText`, `deleteContentBackward`, `insertFromPaste`, and `formatBold`. For a complete list of the -available input types, see the [Attributes section of the Input Events Level 1 spec](https://rawgit.com/w3c/input-events/v1/index.html#interface-InputEvent-Attributes). +available input types, see the [Attributes section of the Input Events Level 2 spec](https://w3c.github.io/input-events/#interface-InputEvent-Attributes). ## Examples -This example logs the `inputType` for [input events](/en-US/docs/Web/API/HTMLElement/input_event) on an editable +This example logs the `inputType` for [input events](/en-US/docs/Web/API/Element/input_event) on an editable {{htmlElement("div")}}. ### HTML diff --git a/files/en-us/web/api/installevent/index.md b/files/en-us/web/api/installevent/index.md index 5baab603c265c2c..1a4a283aa047721 100644 --- a/files/en-us/web/api/installevent/index.md +++ b/files/en-us/web/api/installevent/index.md @@ -10,14 +10,14 @@ browser-compat: api.InstallEvent {{APIRef("Service Workers API")}}{{Deprecated_Header}}{{Non-standard_Header}} +> **Note:** Instead of using the deprecated `ServiceWorkerGlobalScope.oninstall` handler to catch events of this type, handle the (non-deprecated) {{domxref("ServiceWorkerGlobalScope/install_event", "install")}} event using a listener added with {{domxref("EventTarget/addEventListener", "addEventListener")}}. + The parameter passed into the {{domxref("ServiceWorkerGlobalScope.install_event", "oninstall")}} handler, the `InstallEvent` interface represents an install action that is dispatched on the {{domxref("ServiceWorkerGlobalScope")}} of a {{domxref("ServiceWorker")}}. As a child of {{domxref("ExtendableEvent")}}, it ensures that functional events such as {{domxref("FetchEvent")}} are not dispatched during installation. This interface inherits from the {{domxref("ExtendableEvent")}} interface. {{InheritanceDiagram}} -> **Note:** Instead of using the deprecated `ServiceWorkerGlobalScope.oninstall()` handler to catch events of this type, instead handle the (non-deprecated) [`install`](/en-US/docs/Web/API/ServiceWorkerGlobalScope/install_event) using a listener added with [`addEventListener()`](/en-US/docs/Web/API/EventTarget/addEventListener). - ## Constructor - {{domxref("InstallEvent.InstallEvent", "InstallEvent()")}} {{Deprecated_Inline}} {{Non-standard_Inline}} diff --git a/files/en-us/web/api/intersection_observer_api/index.md b/files/en-us/web/api/intersection_observer_api/index.md index 4bc254361aa2666..023967a988a7d53 100644 --- a/files/en-us/web/api/intersection_observer_api/index.md +++ b/files/en-us/web/api/intersection_observer_api/index.md @@ -170,8 +170,8 @@ To get a feeling for how thresholds work, try scrolling the box below around. Ea position: relative; left: 175px; width: 150px; - background-color: rgb(245, 170, 140); - border: 2px solid rgb(201, 126, 17); + background-color: rgb(245 170 140); + border: 2px solid rgb(201 126 17); padding: 4px; margin-bottom: 6px; } @@ -199,8 +199,8 @@ To get a feeling for how thresholds work, try scrolling the box below around. Ea sans-serif; position: absolute; margin: 0; - background-color: rgba(255, 255, 255, 0.7); - border: 1px solid rgba(0, 0, 0, 0.7); + background-color: rgb(255 255 255 / 70%); + border: 1px solid rgb(0 0 0 / 70%); width: 3em; height: 18px; padding: 2px; @@ -362,8 +362,8 @@ The CSS isn't terribly important for the purposes of this example; it lays out t ```css #box { - background-color: rgba(40, 40, 190, 1); - border: 4px solid rgb(20, 20, 120); + background-color: rgb(40 40 190 / 100%); + border: 4px solid rgb(20 20 120); transition: background-color 1s, border 1s; @@ -384,7 +384,7 @@ The CSS isn't terribly important for the purposes of this example; it lays out t width: 350px; height: 350px; margin-top: 10px; - border: 4px solid rgb(20, 20, 120); + border: 4px solid rgb(20 20 120); text-align: center; padding: 20px; } @@ -403,8 +403,8 @@ const numSteps = 20.0; let boxElement; let prevRatio = 0.0; -let increasingColor = "rgba(40, 40, 190, ratio)"; -let decreasingColor = "rgba(190, 40, 40, ratio)"; +let increasingColor = "rgb(40 40 190 / ratio)"; +let decreasingColor = "rgb(190 40 40 / ratio)"; // Set things up window.addEventListener( @@ -582,7 +582,7 @@ function handleIntersect(entries, observer) { } ``` -For each {{domxref("IntersectionObserverEntry")}} in the list `entries`, we look to see if the entry's {{domxref("IntersectionObserverEntry.intersectionRatio", "intersectionRatio")}} is going up; if it is, we set the target's {{cssxref("background-color")}} to the string in `increasingColor` (remember, it's `"rgba(40, 40, 190, ratio)"`), replaces the word "ratio" with the entry's `intersectionRatio`. The result: not only does the color get changed, but the transparency of the target element changes, too; as the intersection ratio goes down, the background color's alpha value goes down with it, resulting in an element that's more transparent. +For each {{domxref("IntersectionObserverEntry")}} in the list `entries`, we look to see if the entry's {{domxref("IntersectionObserverEntry.intersectionRatio", "intersectionRatio")}} is going up; if it is, we set the target's {{cssxref("background-color")}} to the string in `increasingColor` (remember, it's `"rgb(40 40 190 / ratio)"`), replaces the word "ratio" with the entry's `intersectionRatio`. The result: not only does the color get changed, but the transparency of the target element changes, too; as the intersection ratio goes down, the background color's alpha value goes down with it, resulting in an element that's more transparent. Similarly, if the `intersectionRatio` is going down, we use the string `decreasingColor` and replace the word "ratio" in that with the `intersectionRatio` before setting the target element's `background-color`. diff --git a/files/en-us/web/api/intersection_observer_api/timing_element_visibility/index.md b/files/en-us/web/api/intersection_observer_api/timing_element_visibility/index.md index dd9c8228017aab3..6e00a72eb0bb851 100644 --- a/files/en-us/web/api/intersection_observer_api/timing_element_visibility/index.md +++ b/files/en-us/web/api/intersection_observer_api/timing_element_visibility/index.md @@ -185,7 +185,7 @@ Finally, the ads have the following initial styling. Individual ads may customiz font-size: 14px; bottom: 30px; border: 1px solid black; - background-color: rgba(255, 255, 255, 0.5); + background-color: rgb(255 255 255 / 50%); } ``` @@ -316,7 +316,7 @@ function intersectionCallback(entries) { As previously mentioned, the {{domxref("IntersectionObserver")}} callback receives as input an array of all of the observer's targeted elements which have become either more or less visible than one of the intersection observer ratios. We iterate over each of those entries—which are of type {{domxref("IntersectionObserverEntry")}}. If the target element is intersecting with the root, we know it has just transitioned from the obscured state to the visible state. If it's become at least 75% visible, then we consider the ad visible and we start the timer by setting the ad's `dataset.lastViewStarted` attribute to the transition time in {{domxref("IntersectionObserverEntry.time", "entry.time")}}, then add the ad to the set `visibleAds` so we know to process it as time goes by. -If the ad has transitioned to the not-intersecting state, we remove the ad from the set of visible ads. Then we have one special behavior: we look to see if {{domxref("IntersectionObserverEntry.intersectionRatio", "entry.ratio")}} is 0.0; if it is, that means the element has become totally obscured. If that's the case, and the ad has been visible for at least a minute total, we call a function we'll create called `replaceAd()` to replace the existing ad with a new one. This way, the user sees a variety of ads over time, but the ads are only replaced while they can't be seen, resulting in a smooth experience. +If the ad has transitioned to the not-intersecting state, we remove the ad from the set of visible ads. Then we have one special behavior: we look to see if {{domxref("IntersectionObserverEntry.intersectionRatio", "entry.intersectionRatio")}} is 0.0; if it is, that means the element has become totally obscured. If that's the case, and the ad has been visible for at least a minute total, we call a function we'll create called `replaceAd()` to replace the existing ad with a new one. This way, the user sees a variety of ads over time, but the ads are only replaced while they can't be seen, resulting in a smooth experience. #### Handling periodic actions diff --git a/files/en-us/web/api/intersectionobserver/intersectionobserver/index.md b/files/en-us/web/api/intersectionobserver/intersectionobserver/index.md index 45718c94fbc4719..ea85b339ac50a91 100644 --- a/files/en-us/web/api/intersectionobserver/intersectionobserver/index.md +++ b/files/en-us/web/api/intersectionobserver/intersectionobserver/index.md @@ -37,13 +37,13 @@ new IntersectionObserver(callback, options) - `options` {{optional_inline}} - - : An optional object which customizes the observer. - If `options` isn't specified, the observer uses the document's viewport as the root, with no margin, and a 0% threshold (meaning that even a one-pixel change is enough to trigger a callback). + - : An optional object which customizes the observer. All properties are optional. You can provide any combination of the following options: - `root` - : An {{domxref("Element")}} or {{domxref("Document")}} object which is an ancestor of the intended target, whose bounding rectangle will be considered the viewport. - Any part of the target not visible in the visible area of the `root` is not considered visible. + Any part of the target not visible in the visible area of the `root` is not considered visible. If not specified, the observer uses the document's + viewport as the root, with no margin, and a 0% threshold (meaning that even a one-pixel change is enough to trigger a callback). - `rootMargin` - : A string which specifies a set of offsets to add to the root's {{Glossary('bounding_box')}} when calculating intersections, effectively shrinking or growing the root for calculation purposes. diff --git a/files/en-us/web/api/keyboardevent/charcode/index.md b/files/en-us/web/api/keyboardevent/charcode/index.md index 3f60d009aebe835..e69af7793e8fd47 100644 --- a/files/en-us/web/api/keyboardevent/charcode/index.md +++ b/files/en-us/web/api/keyboardevent/charcode/index.md @@ -71,7 +71,7 @@ input.addEventListener("keypress", (e) => { - To get the code of the key regardless of whether it was stored in `keyCode` or `charCode`, query the {{ domxref("UIEvent/which", "which") }} property. -- Characters entered through an IME do not register through `keyCode` or +- Characters entered through an {{glossary("IME")}} do not register through `keyCode` or `charCode`. - For a list of the `charCode` values associated with particular keys, run [Example 7: Displaying Event Object Properties](/en-US/docs/Web/API/Document_Object_Model/Examples#example_7_displaying_event_object_properties) and view the resulting HTML table. diff --git a/files/en-us/web/api/keyboardevent/index.md b/files/en-us/web/api/keyboardevent/index.md index fa7a82bbf5a6c94..53690f335290d9d 100644 --- a/files/en-us/web/api/keyboardevent/index.md +++ b/files/en-us/web/api/keyboardevent/index.md @@ -9,7 +9,7 @@ browser-compat: api.KeyboardEvent **`KeyboardEvent`** objects describe a user interaction with the keyboard; each event describes a single interaction between the user and a key (or combination of a key with modifier keys) on the keyboard. The event type ({{domxref("Element/keydown_event", "keydown")}}, {{domxref("Element/keypress_event", "keypress")}}, or {{domxref("Element/keyup_event", "keyup")}}) identifies what kind of keyboard activity occurred. -> **Note:** `KeyboardEvent` events just indicate what interaction the user had with a key on the keyboard at a low level, providing no contextual meaning to that interaction. When you need to handle text input, use the {{domxref("HTMLElement/input_event", "input")}} event instead. Keyboard events may not be fired if the user is using an alternate means of entering text, such as a handwriting system on a tablet or graphics tablet. +> **Note:** `KeyboardEvent` events just indicate what interaction the user had with a key on the keyboard at a low level, providing no contextual meaning to that interaction. When you need to handle text input, use the {{domxref("Element/input_event", "input")}} event instead. Keyboard events may not be fired if the user is using an alternate means of entering text, such as a handwriting system on a tablet or graphics tablet. {{InheritanceDiagram}} @@ -139,12 +139,6 @@ _This interface also inherits properties of its parents, {{domxref("UIEvent")}} ### Obsolete properties -- {{domxref("KeyboardEvent.char")}} {{Non-standard_inline}} {{Deprecated_inline}} {{ReadOnlyInline}} - - - : Returns a string representing the character value of the key. If the key corresponds to a printable character, this value is a non-empty Unicode string containing that character. If the key doesn't have a printable representation, this is an empty string. - - > **Note:** If the key is used as a macro that inserts multiple characters, this property's value is the entire string, not just the first character. - - {{domxref("KeyboardEvent.charCode")}} {{Deprecated_inline}} {{ReadOnlyInline}} - : Returns a number representing the Unicode reference number of the key; this property is used only by the `keypress` event. For keys whose `char` property contains multiple characters, this is the Unicode value of the first character in that property. In Firefox 26 this returns codes for printable characters. @@ -159,8 +153,6 @@ _This interface also inherits properties of its parents, {{domxref("UIEvent")}} - {{domxref("KeyboardEvent.keyIdentifier")}} {{Non-standard_inline}} {{deprecated_inline}} {{ReadOnlyInline}} - : This property is non-standard and has been deprecated in favor of {{domxref("KeyboardEvent.key")}}. It was part of an old version of DOM Level 3 Events. -- {{domxref("KeyboardEvent.keyLocation")}} {{Non-standard_inline}} {{deprecated_inline}} {{ReadOnlyInline}} - - : This is a non-standard deprecated alias for {{domxref("KeyboardEvent.location")}}. It was part of an old version of DOM Level 3 Events. ## Instance methods diff --git a/files/en-us/web/api/keyboardevent/key/index.md b/files/en-us/web/api/keyboardevent/key/index.md index 2cbaecba413c405..b03478baacf4a6f 100644 --- a/files/en-us/web/api/keyboardevent/key/index.md +++ b/files/en-us/web/api/keyboardevent/key/index.md @@ -32,7 +32,7 @@ Its value is determined as follows: Every `KeyboardEvent` is fired in a pre-determined sequence. For a given key press, the sequence of `KeyboardEvent`s fired is as follows assuming that {{domxref("Event.preventDefault")}} is not called: 1. A {{domxref("Element/keydown_event", "keydown")}} event is first fired. If the key is held down further and the key produces a character key, then the event continues to be emitted in a platform implementation dependent interval and the {{domxref("KeyboardEvent.repeat")}} read only property is set to `true`. -2. If the key produces a character key that would result in a character being inserted into possibly an {{HTMLElement("input")}}, {{HTMLElement("textarea")}} or an element with {{domxref("HTMLElement.contentEditable")}} set to true, the {{domxref("HTMLElement/beforeinput_event", "beforeinput")}} and {{domxref("HTMLElement/input_event", "input")}} event types are fired in that order. Note that some other implementations may fire {{domxref("Element/keypress_event", "keypress")}} event if supported. The events will be fired repeatedly while the key is held down. +2. If the key produces a character key that would result in a character being inserted into possibly an {{HTMLElement("input")}}, {{HTMLElement("textarea")}} or an element with {{domxref("HTMLElement.contentEditable")}} set to true, the {{domxref("Element/beforeinput_event", "beforeinput")}} and {{domxref("Element/input_event", "input")}} event types are fired in that order. Note that some other implementations may fire {{domxref("Element/keypress_event", "keypress")}} event if supported. The events will be fired repeatedly while the key is held down. 3. A {{domxref("Element/keyup_event", "keyup")}} event is fired once the key is released. This completes the process. In sequence 1 & 3, the `KeyboardEvent.key` attribute is defined and is set appropriately to a value according to the rules defined earlier. @@ -165,13 +165,13 @@ btnReset.addEventListener("click", (e) => { {{EmbedLiveSample('KeyboardEvent_sequence_example')}} -> **Note:** On browsers that don't fully implement the {{domxref("InputEvent")}} interface which is used for the {{domxref("HTMLElement/beforeinput_event", "beforeinput")}} and {{domxref("HTMLElement/input_event", "input")}} events, you may get incorrect output on those lines of the log output. +> **Note:** On browsers that don't fully implement the {{domxref("InputEvent")}} interface which is used for the {{domxref("Element/beforeinput_event", "beforeinput")}} and {{domxref("Element/input_event", "input")}} events, you may get incorrect output on those lines of the log output. ### Case 1 When the shift key is pressed, a {{domxref("Element/keydown_event", "keydown")}} event is first fired, and the `key` property value is set to the string `Shift`. As we keep holding this key, the {{domxref("Element/keydown_event", "keydown")}} event does not continue to fire repeatedly because it does not produce a character key. -When `key 2` is pressed, another {{domxref("Element/keydown_event", "keydown")}} event is fired for this new key press, and the `key` property value for the event is set to the string `@` for the U.S keyboard type and `"` for the UK keyboard type, because of the active modifier `shift` key. The {{domxref("HTMLElement/beforeinput_event", "beforeinput")}} and {{domxref("HTMLElement/input_event", "input")}} events are fired next because a character key has been produced. +When `key 2` is pressed, another {{domxref("Element/keydown_event", "keydown")}} event is fired for this new key press, and the `key` property value for the event is set to the string `@` for the U.S keyboard type and `"` for the UK keyboard type, because of the active modifier `shift` key. The {{domxref("Element/beforeinput_event", "beforeinput")}} and {{domxref("Element/input_event", "input")}} events are fired next because a character key has been produced. As we release the `key 2`, a {{domxref("Element/keyup_event", "keyup")}} event is fired and the `key` property will maintain the string values `@` and `"` for the different keyboard layouts respectively. @@ -181,9 +181,9 @@ As we finally release the `shift` key, another {{domxref("Element/keyup_event", When the shift key is pressed, a {{domxref("Element/keydown_event", "keydown")}} event is first fired, and the `key` property value is set to be the string `Shift`. As we keep holding this key, the keydown event does not continue to fire repeatedly because it produced no character key. -When `key 2` is pressed, another {{domxref("Element/keydown_event", "keydown")}} event is fired for this new key press, and the `key` property value for the event is set to be the string `@` for the U.S keyboard type and `"` for the UK keyboard type, because of the active modifier `shift` key. The {{domxref("HTMLElement/beforeinput_event", "beforeinput")}} and {{domxref("HTMLElement/input_event", "input")}} events are fired next because a character key has been produced. As we keep holding the key, the {{domxref("Element/keydown_event", "keydown")}} event continues to fire repeatedly and the {{domxref("KeyboardEvent.repeat")}} property is set to `true`. The {{domxref("HTMLElement/beforeinput_event", "beforeinput")}} and {{domxref("HTMLElement/input_event", "input")}} events are fired repeatedly as well. +When `key 2` is pressed, another {{domxref("Element/keydown_event", "keydown")}} event is fired for this new key press, and the `key` property value for the event is set to be the string `@` for the U.S keyboard type and `"` for the UK keyboard type, because of the active modifier `shift` key. The {{domxref("Element/beforeinput_event", "beforeinput")}} and {{domxref("Element/input_event", "input")}} events are fired next because a character key has been produced. As we keep holding the key, the {{domxref("Element/keydown_event", "keydown")}} event continues to fire repeatedly and the {{domxref("KeyboardEvent.repeat")}} property is set to `true`. The {{domxref("Element/beforeinput_event", "beforeinput")}} and {{domxref("Element/input_event", "input")}} events are fired repeatedly as well. -As we release the `shift` key, a {{domxref("Element/keyup_event", "keyup")}} event is fired for it, and the key attribute value remains `Shift`. At this point, notice that the `key` property value for the repeating keydown event of the `key 2` key press is now "2" because the modifier `shift` key is no longer active. The same goes for the {{domxref("InputEvent.data")}} property of the {{domxref("HTMLElement/beforeinput_event", "beforeinput")}} and {{domxref("HTMLElement/input_event", "input")}} events. +As we release the `shift` key, a {{domxref("Element/keyup_event", "keyup")}} event is fired for it, and the key attribute value remains `Shift`. At this point, notice that the `key` property value for the repeating keydown event of the `key 2` key press is now "2" because the modifier `shift` key is no longer active. The same goes for the {{domxref("InputEvent.data")}} property of the {{domxref("Element/beforeinput_event", "beforeinput")}} and {{domxref("Element/input_event", "input")}} events. As we finally release the `key 2`, a {{domxref("Element/keyup_event", "keyup")}} event is fired but the `key` property will be set to the string value `2` for both keyboard layouts because the modifier `shift` key is no longer active. diff --git a/files/en-us/web/api/keyboardevent/keycode/index.md b/files/en-us/web/api/keyboardevent/keycode/index.md index e8a06199bf66ea9..2d5f7d7106e9c69 100644 --- a/files/en-us/web/api/keyboardevent/keycode/index.md +++ b/files/en-us/web/api/keyboardevent/keycode/index.md @@ -2971,7 +2971,7 @@ Gecko defines a lot of `keyCode` values in `KeyboardEvent` for making the mappin DOM_VK_DOUBLE_QUOTE - 0xA3 (162) + 0xA2 (162) Double quote (""") key. diff --git a/files/en-us/web/api/keyboardlayoutmap/has/index.md b/files/en-us/web/api/keyboardlayoutmap/has/index.md index a058bc0e5c5ea71..1602188e4c01516 100644 --- a/files/en-us/web/api/keyboardlayoutmap/has/index.md +++ b/files/en-us/web/api/keyboardlayoutmap/has/index.md @@ -37,7 +37,7 @@ A {{jsxref('Boolean')}} indicating whether the specified key was found. ## Examples -The following example checks whether the location- or layout-specific string associated with the keyboard code that corresponds to the 'W' key on an English QWERTY keyboard existes. +The following example checks whether the location- or layout-specific string associated with the keyboard code that corresponds to the 'W' key on an English QWERTY keyboard exists. ```js navigator.keyboard.getLayoutMap().then((keyboardLayoutMap) => { diff --git a/files/en-us/web/api/largestcontentfulpaint/element/index.md b/files/en-us/web/api/largestcontentfulpaint/element/index.md index 9d0dac0867dd713..3fd765b8d876c91 100644 --- a/files/en-us/web/api/largestcontentfulpaint/element/index.md +++ b/files/en-us/web/api/largestcontentfulpaint/element/index.md @@ -3,12 +3,10 @@ title: "LargestContentfulPaint: element property" short-title: element slug: Web/API/LargestContentfulPaint/element page-type: web-api-instance-property -status: - - experimental browser-compat: api.LargestContentfulPaint.element --- -{{APIRef("Performance API")}}{{SeeCompatTable}} +{{APIRef("Performance API")}} The **`element`** read-only property of the {{domxref("LargestContentfulPaint")}} interface returns an object representing the {{domxref("Element")}} that is the largest contentful paint. diff --git a/files/en-us/web/api/largestcontentfulpaint/id/index.md b/files/en-us/web/api/largestcontentfulpaint/id/index.md index ed38278175c0c48..16bbf18c34fb025 100644 --- a/files/en-us/web/api/largestcontentfulpaint/id/index.md +++ b/files/en-us/web/api/largestcontentfulpaint/id/index.md @@ -3,12 +3,10 @@ title: "LargestContentfulPaint: id property" short-title: id slug: Web/API/LargestContentfulPaint/id page-type: web-api-instance-property -status: - - experimental browser-compat: api.LargestContentfulPaint.id --- -{{APIRef("Performance API")}}{{SeeCompatTable}} +{{APIRef("Performance API")}} The **`id`** read-only property of the {{domxref("LargestContentfulPaint")}} interface returns the ID of the element that is the largest contentful paint. diff --git a/files/en-us/web/api/largestcontentfulpaint/index.md b/files/en-us/web/api/largestcontentfulpaint/index.md index 90df09970c3d77a..8b9953bc1a4de44 100644 --- a/files/en-us/web/api/largestcontentfulpaint/index.md +++ b/files/en-us/web/api/largestcontentfulpaint/index.md @@ -2,12 +2,10 @@ title: LargestContentfulPaint slug: Web/API/LargestContentfulPaint page-type: web-api-interface -status: - - experimental browser-compat: api.LargestContentfulPaint --- -{{APIRef("Performance API")}}{{SeeCompatTable}} +{{APIRef("Performance API")}} The `LargestContentfulPaint` interface provides timing information about the largest image or text paint before user input on a web page. @@ -47,24 +45,24 @@ This interface extends the following {{domxref("PerformanceEntry")}} properties It also supports the following properties: -- {{domxref("LargestContentfulPaint.element")}} {{ReadOnlyInline}} {{Experimental_Inline}} +- {{domxref("LargestContentfulPaint.element")}} {{ReadOnlyInline}} - : The element that is the current largest contentful paint. -- {{domxref("LargestContentfulPaint.renderTime")}} {{ReadOnlyInline}} {{Experimental_Inline}} +- {{domxref("LargestContentfulPaint.renderTime")}} {{ReadOnlyInline}} - : The time the element was rendered to the screen. May not be available if the element is a cross-origin image loaded without the `Timing-Allow-Origin` header. -- {{domxref("LargestContentfulPaint.loadTime")}} {{ReadOnlyInline}} {{Experimental_Inline}} +- {{domxref("LargestContentfulPaint.loadTime")}} {{ReadOnlyInline}} - : The time the element was loaded. -- {{domxref("LargestContentfulPaint.size")}} {{ReadOnlyInline}} {{Experimental_Inline}} +- {{domxref("LargestContentfulPaint.size")}} {{ReadOnlyInline}} - : The intrinsic size of the element returned as the area (width \* height). -- {{domxref("LargestContentfulPaint.id")}} {{ReadOnlyInline}} {{Experimental_Inline}} +- {{domxref("LargestContentfulPaint.id")}} {{ReadOnlyInline}} - : The id of the element. This property returns an empty string when there is no id. -- {{domxref("LargestContentfulPaint.url")}} {{ReadOnlyInline}} {{Experimental_Inline}} +- {{domxref("LargestContentfulPaint.url")}} {{ReadOnlyInline}} - : If the element is an image, the request url of the image. ## Instance methods _This interface also inherits methods from {{domxref("PerformanceEntry")}}._ -- {{domxref("LargestContentfulPaint.toJSON()")}} {{Experimental_Inline}} +- {{domxref("LargestContentfulPaint.toJSON()")}} - : Returns a JSON representation of the `LargestContentfulPaint` object. ## Examples diff --git a/files/en-us/web/api/largestcontentfulpaint/loadtime/index.md b/files/en-us/web/api/largestcontentfulpaint/loadtime/index.md index 4357f7f8d7218f4..e058226fe2714f9 100644 --- a/files/en-us/web/api/largestcontentfulpaint/loadtime/index.md +++ b/files/en-us/web/api/largestcontentfulpaint/loadtime/index.md @@ -3,12 +3,10 @@ title: "LargestContentfulPaint: loadTime property" short-title: loadTime slug: Web/API/LargestContentfulPaint/loadTime page-type: web-api-instance-property -status: - - experimental browser-compat: api.LargestContentfulPaint.loadTime --- -{{APIRef("Performance API")}}{{SeeCompatTable}} +{{APIRef("Performance API")}} The **`loadTime`** read-only property of the {{domxref("LargestContentfulPaint")}} interface returns the time that the element was loaded. diff --git a/files/en-us/web/api/largestcontentfulpaint/rendertime/index.md b/files/en-us/web/api/largestcontentfulpaint/rendertime/index.md index 955a2ead7ba9bcf..78d8a805a155a4a 100644 --- a/files/en-us/web/api/largestcontentfulpaint/rendertime/index.md +++ b/files/en-us/web/api/largestcontentfulpaint/rendertime/index.md @@ -3,12 +3,10 @@ title: "LargestContentfulPaint: renderTime property" short-title: renderTime slug: Web/API/LargestContentfulPaint/renderTime page-type: web-api-instance-property -status: - - experimental browser-compat: api.LargestContentfulPaint.renderTime --- -{{APIRef("Performance API")}}{{SeeCompatTable}} +{{APIRef("Performance API")}} The **`renderTime`** read-only property of the {{domxref("LargestContentfulPaint")}} interface represents the time that the element was rendered to the screen. diff --git a/files/en-us/web/api/largestcontentfulpaint/size/index.md b/files/en-us/web/api/largestcontentfulpaint/size/index.md index d5213a543aa08b4..27fce44948af4a2 100644 --- a/files/en-us/web/api/largestcontentfulpaint/size/index.md +++ b/files/en-us/web/api/largestcontentfulpaint/size/index.md @@ -3,12 +3,10 @@ title: "LargestContentfulPaint: size property" short-title: size slug: Web/API/LargestContentfulPaint/size page-type: web-api-instance-property -status: - - experimental browser-compat: api.LargestContentfulPaint.size --- -{{APIRef("Performance API")}}{{SeeCompatTable}} +{{APIRef("Performance API")}} The **`size`** read-only property of the {{domxref("LargestContentfulPaint")}} interface returns the intrinsic size of the element that is the largest contentful paint. diff --git a/files/en-us/web/api/largestcontentfulpaint/tojson/index.md b/files/en-us/web/api/largestcontentfulpaint/tojson/index.md index 127ddc3cc9d3ccd..32ec5e6cf374cc6 100644 --- a/files/en-us/web/api/largestcontentfulpaint/tojson/index.md +++ b/files/en-us/web/api/largestcontentfulpaint/tojson/index.md @@ -3,12 +3,10 @@ title: "LargestContentfulPaint: toJSON() method" short-title: toJSON() slug: Web/API/LargestContentfulPaint/toJSON page-type: web-api-instance-method -status: - - experimental browser-compat: api.LargestContentfulPaint.toJSON --- -{{APIRef("Performance API")}}{{SeeCompatTable}} +{{APIRef("Performance API")}} The **`toJSON()`** method of the {{domxref("LargestContentfulPaint")}} interface is a {{Glossary("Serialization","serializer")}}; it returns a JSON representation of the {{domxref("LargestContentfulPaint")}} object. diff --git a/files/en-us/web/api/largestcontentfulpaint/url/index.md b/files/en-us/web/api/largestcontentfulpaint/url/index.md index 5c418edb06709f9..2a7b0125d02b129 100644 --- a/files/en-us/web/api/largestcontentfulpaint/url/index.md +++ b/files/en-us/web/api/largestcontentfulpaint/url/index.md @@ -3,12 +3,10 @@ title: "LargestContentfulPaint: url property" short-title: url slug: Web/API/LargestContentfulPaint/url page-type: web-api-instance-property -status: - - experimental browser-compat: api.LargestContentfulPaint.url --- -{{APIRef("Performance API")}}{{SeeCompatTable}} +{{APIRef("Performance API")}} The **`url`** read-only property of the {{domxref("LargestContentfulPaint")}} interface returns the request URL of the element, if the element is an image. diff --git a/files/en-us/web/api/linearaccelerationsensor/index.md b/files/en-us/web/api/linearaccelerationsensor/index.md index 28667c205953e13..87caa22802b78e5 100644 --- a/files/en-us/web/api/linearaccelerationsensor/index.md +++ b/files/en-us/web/api/linearaccelerationsensor/index.md @@ -5,7 +5,7 @@ page-type: web-api-interface browser-compat: api.LinearAccelerationSensor --- -{{APIRef("Sensor API")}} +{{securecontext_header}}{{APIRef("Sensor API")}} The **`LinearAccelerationSensor`** interface of the [Sensor APIs](/en-US/docs/Web/API/Sensor_APIs) provides on each reading the acceleration applied to the device along all three axes, but without the contribution of gravity. diff --git a/files/en-us/web/api/linearaccelerationsensor/linearaccelerationsensor/index.md b/files/en-us/web/api/linearaccelerationsensor/linearaccelerationsensor/index.md index ef79bb40932de1b..c7ae8cf61ac7e6b 100644 --- a/files/en-us/web/api/linearaccelerationsensor/linearaccelerationsensor/index.md +++ b/files/en-us/web/api/linearaccelerationsensor/linearaccelerationsensor/index.md @@ -6,7 +6,7 @@ page-type: web-api-constructor browser-compat: api.LinearAccelerationSensor.LinearAccelerationSensor --- -{{APIRef("Sensor API")}} +{{securecontext_header}}{{APIRef("Sensor API")}} The **`LinearAccelerationSensor()`** constructor creates a new {{domxref("LinearAccelerationSensor")}} object which @@ -26,13 +26,13 @@ new LinearAccelerationSensor(options) - : Options are as follows: - - `frequency` + - `frequency` {{optional_inline}} - : The desired number of times per second a sample should be taken, meaning the number of times per second that the {{domxref('sensor.reading_event', 'reading')}} event will be called. A whole number or decimal may be used, the latter for frequencies less than a second. The actual reading frequency depends on device hardware and consequently may be less than requested. - - `referenceFrame` + - `referenceFrame` {{optional_inline}} - : Either `'device'` or `'screen'`. The default is `'device'`. diff --git a/files/en-us/web/api/location/assign/index.md b/files/en-us/web/api/location/assign/index.md index 9c47e8485ba58a3..a659d1f0c5aae2d 100644 --- a/files/en-us/web/api/location/assign/index.md +++ b/files/en-us/web/api/location/assign/index.md @@ -8,19 +8,10 @@ browser-compat: api.Location.assign {{ APIRef("HTML DOM") }} -The **`Location.assign()`** method causes the window to load +The **`assign()`** method of the {{DOMXref("Location")}} +interface causes the window to load and display the document at the URL specified. After the navigation occurs, the user can -navigate back to the page that called `Location.assign()` by pressing the -"back" button. - -If the assignment can't happen because of a security violation, a -{{domxref("DOMException")}} of the `SECURITY_ERROR` type is thrown. This -happens if the origin of the script calling the method is different from the origin of -the page originally described by the {{domxref("Location")}} object, mostly when the -script is hosted on a different domain. - -If the provided URL is not valid, a {{domxref("DOMException")}} of the -`SYNTAX_ERROR` type is thrown. +navigate back to the page that called `Location.assign()` by pressing the "back" button. ## Syntax @@ -33,6 +24,13 @@ assign(url) - `url` - : A string containing the URL of the page to navigate to; for example, an absolute URL such as `https://developer.mozilla.org/en-US/docs/Web/API/Location/reload`, or a relative URL — such as `"/Web` (just a path, for navigating to another document at the same origin) or `#specifications` (just a fragment string, for navigating to some part of the same page), and so on. +### Exceptions + +- `SecurityError` {{domxref("DOMException")}} + - : Thrown if the {{Glossary("origin")}} of the script calling the method is not the {{Glossary("Same-origin policy", "same origin")}} of the page originally described by the {{domxref("Location")}} object, mostly when the script is hosted on a different domain. +- `SyntaxError` {{domxref("DOMException")}} + - : Thrown if the provided `url` parameter is not a valid URL. + ### Return value None ({{jsxref("undefined")}}). diff --git a/files/en-us/web/api/location/hostname/index.md b/files/en-us/web/api/location/hostname/index.md index 4fb278f258e162e..456396bb36cc702 100644 --- a/files/en-us/web/api/location/hostname/index.md +++ b/files/en-us/web/api/location/hostname/index.md @@ -18,10 +18,8 @@ A string. ## Examples ```js -const anchor = document.createElement("a"); -anchor.href = "https://developer.mozilla.org:4097/en-US/docs/Location.hostname"; - -console.log(anchor.hostname); // developer.mozilla.org +console.log(window.location.hostname); +// developer.mozilla.org ``` ## Specifications diff --git a/files/en-us/web/api/location/index.md b/files/en-us/web/api/location/index.md index cdd0c140f1be718..c1262a12cd5b753 100644 --- a/files/en-us/web/api/location/index.md +++ b/files/en-us/web/api/location/index.md @@ -91,7 +91,7 @@ body { :target { position: relative; z-index: 1; - outline: 50em solid rgba(255, 255, 255, 0.8); + outline: 50em solid rgb(255 255 255 / 80%); } ``` diff --git a/files/en-us/web/api/location/reload/index.md b/files/en-us/web/api/location/reload/index.md index fb53fbe2b4f4e02..df9920c43502255 100644 --- a/files/en-us/web/api/location/reload/index.md +++ b/files/en-us/web/api/location/reload/index.md @@ -8,13 +8,7 @@ browser-compat: api.Location.reload {{ APIRef("HTML DOM") }} -The **`location.reload()`** method reloads the current URL, like the Refresh button. - -The reload may be blocked and a `SECURITY_ERROR` {{domxref("DOMException")}} -thrown. This happens if the {{Glossary("origin")}} of the script calling -`location.reload()` differs from the origin of the page that owns the -{{domxref("Location")}} object. See [Same-origin policy](/en-US/docs/Web/Security/Same-origin_policy) for more -information. +The **`reload()`** method of the {{DOMXref("Location")}} interface reloads the current URL, like the Refresh button. ## Syntax @@ -31,6 +25,11 @@ reload() None ({{jsxref("undefined")}}). +### Exceptions + +- `SecurityError` {{domxref("DOMException")}} + - : Thrown if the {{Glossary("origin")}} of the script calling the method is not the {{Glossary("Same-origin policy", "same origin")}} of the page originally described by the {{domxref("Location")}} object, mostly when the script is hosted on a different domain. + ## Specifications {{Specifications}} diff --git a/files/en-us/web/api/location/replace/index.md b/files/en-us/web/api/location/replace/index.md index edc8c739b305a42..aa38c7e0f3fbb3d 100644 --- a/files/en-us/web/api/location/replace/index.md +++ b/files/en-us/web/api/location/replace/index.md @@ -11,18 +11,8 @@ browser-compat: api.Location.replace The **`replace()`** method of the {{DOMXref("Location")}} interface replaces the current resource with the one at the provided URL. The difference from the {{domxref("Location.assign","assign()")}} method is that after using -`replace()` the current page will not be saved in session -{{domxref("History")}}, meaning the user won't be able to use the _back_ button -to navigate to it. - -If the assignment can't happen because of a security violation, a -{{domxref("DOMException")}} of the `SECURITY_ERROR` type is thrown. This -happens if the origin of the script calling the method is different from the origin of -the page originally described by the {{domxref("Location")}} object, mostly when the -script is hosted on a different domain. - -If the provided URL is not valid, a {{domxref("DOMException")}} of the -`SYNTAX_ERROR` type is thrown. +`replace()` the current page will not be saved in session {{domxref("History")}}, +meaning the user won't be able to use the _back_ button to navigate to it. ## Syntax @@ -35,6 +25,11 @@ replace(url) - `url` - : A string containing the URL of the page to navigate to. +### Exceptions + +- `SyntaxError` {{domxref("DOMException")}} + - : Thrown if the provided `url` parameter is not a valid URL. + ### Return value None ({{jsxref("undefined")}}). diff --git a/files/en-us/web/api/lock/index.md b/files/en-us/web/api/lock/index.md index 4754cd7de1ce405..d88600547e14f1d 100644 --- a/files/en-us/web/api/lock/index.md +++ b/files/en-us/web/api/lock/index.md @@ -23,7 +23,7 @@ This may be a newly requested lock that is received in the callback to {{domxref ## Examples The following examples show how the mode and name properties are passed in the call to {{domxref('LockManager.request()')}}. -`LockManager` is the object returned by {{domxref('navigator.locks')}}. +{{domxref('LockManager')}} is the object returned by {{domxref('navigator.locks')}}. ```js navigator.locks.request("net_db_sync", show_lock_properties); diff --git a/files/en-us/web/api/lock/mode/index.md b/files/en-us/web/api/lock/mode/index.md index 84de4ecf58a5f94..9e394000db62091 100644 --- a/files/en-us/web/api/lock/mode/index.md +++ b/files/en-us/web/api/lock/mode/index.md @@ -1,5 +1,5 @@ --- -title: "Locks: mode property" +title: "Lock: mode property" short-title: mode slug: Web/API/Lock/mode page-type: web-api-instance-property @@ -20,7 +20,7 @@ One of `"exclusive"` or `"shared"`. ## Examples The following examples show how the mode property is passed in the call to {{domxref('LockManager.request()')}}. -`LockManager` is the object returned by {{domxref('navigator.locks')}}. +{{domxref('LockManager')}} is the object returned by {{domxref('navigator.locks')}}. ```js // Should show "exclusive" (the default) diff --git a/files/en-us/web/api/lock/name/index.md b/files/en-us/web/api/lock/name/index.md index f69ff693b984ab5..575cdff686053d5 100644 --- a/files/en-us/web/api/lock/name/index.md +++ b/files/en-us/web/api/lock/name/index.md @@ -1,5 +1,5 @@ --- -title: "Locks: name property" +title: "Lock: name property" short-title: name slug: Web/API/Lock/name page-type: web-api-instance-property @@ -27,7 +27,7 @@ A string. ## Examples The following examples show how the name property passed in the call -to {{domxref('LockManager.request()')}}. `LockManager` is the object returned +to {{domxref('LockManager.request()')}}. {{domxref('LockManager')}} is the object returned by {{domxref('navigator.locks')}}. ```js diff --git a/files/en-us/web/api/lockmanager/query/index.md b/files/en-us/web/api/lockmanager/query/index.md index fd54b3700eb5325..03d0efc0ce18125 100644 --- a/files/en-us/web/api/lockmanager/query/index.md +++ b/files/en-us/web/api/lockmanager/query/index.md @@ -27,17 +27,28 @@ None. A {{jsxref('Promise')}} that resolves with an object containing a snapshot of the {{domxref("LockManager")}} state. The object has the following properties: -- `held`: An array of {{domxref('LockInfo')}} objects for held locks. -- `pending`: An array of {{domxref('LockInfo')}} objects for pending lock requests. +- `held` + - : An array of `LockInfo` objects for held locks. +- `pending` + - : An array of `LockInfo` objects for pending lock requests. + +The `LockInfo` object can have the following properties: + +- `name` + - : The name passed to {{domxref("LockManager.request()")}} when the lock was requested. +- `mode` + - : The access mode passed to {{domxref("LockManager.request()")}} when the lock was requested. The mode is either `"exclusive"` or `"shared"`. +- `clientId` + - : The unique identity of the context where {{domxref("LockManager.request()")}} is called. This is the same value as {{domxref("Client.id")}}. ### Exceptions This method may return a promise rejected with a {{domxref("DOMException")}} of one of the following types: - `InvalidStateError` {{domxref("DOMException")}} - - : If the environments document is not fully active. + - : Thrown if the environments document is not fully active. - `SecurityError` {{domxref("DOMException")}} - - : If a lock manager cannot be obtained for the current environment. + - : Thrown if a lock manager cannot be obtained for the current environment. ## Examples diff --git a/files/en-us/web/api/lockmanager/request/index.md b/files/en-us/web/api/lockmanager/request/index.md index 095e2ab51c1a446..5cc067a301d462a 100644 --- a/files/en-us/web/api/lockmanager/request/index.md +++ b/files/en-us/web/api/lockmanager/request/index.md @@ -64,8 +64,8 @@ request(name, options, callback) > Code that was previously running inside the lock continues to run, and may clash with the code that now holds the lock. - `signal` {{optional_inline}} - - : An `AbortSignal` (the `signal` property of an `AbortController`); - if specified and the `AbortController` is aborted, the lock request is dropped if it was not already granted. + - : An {{domxref("AbortSignal")}} (the {{domxref("AbortController.signal", "signal")}} property of an {{domxref("AbortController")}}); + if specified and the {{domxref("AbortController")}} is aborted, the lock request is dropped if it was not already granted. - `callback` - : Method called when the lock is granted. @@ -81,13 +81,13 @@ A {{jsxref('Promise')}} that resolves (or rejects) with the result of the callba This method may return a promise rejected with a {{domxref("DOMException")}} of one of the following types: - `InvalidStateError` {{domxref("DOMException")}} - - : If the environments document is not fully active. + - : Thrown if the environments document is not fully active. - `SecurityError` {{domxref("DOMException")}} - - : If a lock manager cannot be obtained for the current environment. + - : Thrown if a lock manager cannot be obtained for the current environment. - `NotSupportedError` {{domxref("DOMException")}} - - : If `name` starts with a hyphen (`-`), both options `steal` and `ifAvailable` are `true`, or if option `signal` exists and _either_ option `steal` or `ifAvailable` is `true`. + - : Thrown if `name` starts with a hyphen (`-`), both options `steal` and `ifAvailable` are `true`, or if option `signal` exists and _either_ option `steal` or `ifAvailable` is `true`. - `AbortError` {{domxref("DOMException")}} - - : If the option `signal` exists and is aborted. + - : Thrown if the option `signal` exists and is aborted. ## Examples @@ -102,7 +102,7 @@ await navigator.locks.request("my_resource", async (lock) => { }); ``` -### Mode Example +### `mode` example The following example shows how to use the `mode` option for readers and writers. @@ -136,7 +136,7 @@ async function do_write() { } ``` -### ifAvailable Example +### `ifAvailable` example To grab a lock only if it isn't already being held, use the `ifAvailable` option. In this function `await` means the method will not return until the callback is complete. @@ -158,7 +158,7 @@ await navigator.locks.request( ); ``` -### signal Example +### `signal` example To only wait for a lock for a short period of time, use the `signal` option. diff --git a/files/en-us/web/api/magnetometer/index.md b/files/en-us/web/api/magnetometer/index.md index bc50035f0e0d8e3..7b6313d30b27615 100644 --- a/files/en-us/web/api/magnetometer/index.md +++ b/files/en-us/web/api/magnetometer/index.md @@ -7,7 +7,7 @@ status: browser-compat: api.Magnetometer --- -{{APIRef("Sensor API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Sensor API")}}{{SeeCompatTable}} The **`Magnetometer`** interface of the [Sensor APIs](/en-US/docs/Web/API/Sensor_APIs) provides information about the magnetic field as detected by the device's primary magnetometer sensor. diff --git a/files/en-us/web/api/magnetometer/magnetometer/index.md b/files/en-us/web/api/magnetometer/magnetometer/index.md index f8214d4cee9ea5d..0648113b1e8354b 100644 --- a/files/en-us/web/api/magnetometer/magnetometer/index.md +++ b/files/en-us/web/api/magnetometer/magnetometer/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.Magnetometer.Magnetometer --- -{{APIRef("Sensor API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Sensor API")}}{{SeeCompatTable}} The **`Magnetometer()`** constructor creates a new {{domxref("Magnetometer")}} object which returns information about the @@ -27,13 +27,13 @@ new Magnetometer(options) - : Options are as follows: - - `frequency` + - `frequency` {{optional_inline}} - : The desired number of times per second a sample should be taken, meaning the number of times per second that the {{domxref('sensor.reading_event', 'reading')}} event will be called. A whole number or decimal may be used, the latter for frequencies less than a second. The actual reading frequency depends on device hardware and consequently may be less than requested. - - `referenceFrame` + - `referenceFrame` {{optional_inline}} - : Either `'device'` or `'screen'`. The default is `'device'`. diff --git a/files/en-us/web/api/magnetometer/x/index.md b/files/en-us/web/api/magnetometer/x/index.md index 7cc48cb5ddc3ac3..25a2d2ca97a139d 100644 --- a/files/en-us/web/api/magnetometer/x/index.md +++ b/files/en-us/web/api/magnetometer/x/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.Magnetometer.x --- -{{APIRef("Sensor API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Sensor API")}}{{SeeCompatTable}} The **`x`** read-only property of the {{domxref("Magnetometer")}} interface returns a number specifying diff --git a/files/en-us/web/api/magnetometer/y/index.md b/files/en-us/web/api/magnetometer/y/index.md index 6cd6ebff6a3825c..47aa4203bb61df3 100644 --- a/files/en-us/web/api/magnetometer/y/index.md +++ b/files/en-us/web/api/magnetometer/y/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.Magnetometer.y --- -{{APIRef("Sensor API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Sensor API")}}{{SeeCompatTable}} The **`y`** read-only property of the {{domxref("Magnetometer")}} interface returns a number specifying diff --git a/files/en-us/web/api/magnetometer/z/index.md b/files/en-us/web/api/magnetometer/z/index.md index 4a493ff26d45cfc..518a87c0def2fa1 100644 --- a/files/en-us/web/api/magnetometer/z/index.md +++ b/files/en-us/web/api/magnetometer/z/index.md @@ -8,7 +8,7 @@ status: browser-compat: api.Magnetometer.z --- -{{APIRef("Sensor API")}}{{SeeCompatTable}} +{{securecontext_header}}{{APIRef("Sensor API")}}{{SeeCompatTable}} The **`z`** read-only property of the {{domxref("Magnetometer")}} interface returns a number specifying diff --git a/files/en-us/web/api/media_capture_and_streams_api/constraints/index.md b/files/en-us/web/api/media_capture_and_streams_api/constraints/index.md index e0e9c00a40f3ef9..d39da59c0324e1f 100644 --- a/files/en-us/web/api/media_capture_and_streams_api/constraints/index.md +++ b/files/en-us/web/api/media_capture_and_streams_api/constraints/index.md @@ -106,7 +106,7 @@ So-called advanced constraints are created by adding an `advanced` property to t ## Checking capabilities -You can call {{domxref("MediaStreamTrack.getCapabilities()")}} to get a list of all of the supported capabilities and the values or ranges of values which each one accepts on the current platform and user agent*.* This function returns an object which lists each constrainable property supported by the browser and a value or range of values which are supported for each one of those properties. +You can call {{domxref("MediaStreamTrack.getCapabilities()")}} to get a list of all of the supported capabilities and the values or ranges of values which each one accepts on the current platform and user agent. This function returns an object which lists each constrainable property supported by the browser and a value or range of values which are supported for each one of those properties. > **Note:** `getCapabilities()` hasn't been implemented yet by all major browsers. For the time being, you'll have to try to get what you need, and if you can't, decide what to do at that point. See Firefox [Firefox bug 1179084](https://bugzil.la/1179084), for example. diff --git a/files/en-us/web/api/media_capture_and_streams_api/index.md b/files/en-us/web/api/media_capture_and_streams_api/index.md index 334230c3ac0cf0e..f827ce501dc6985 100644 --- a/files/en-us/web/api/media_capture_and_streams_api/index.md +++ b/files/en-us/web/api/media_capture_and_streams_api/index.md @@ -2,7 +2,16 @@ title: Media Capture and Streams API (Media Stream) slug: Web/API/Media_Capture_and_Streams_API page-type: web-api-overview -browser-compat: api.MediaStream +browser-compat: + - api.MediaStream + - api.MediaStreamTrack + - api.MediaDevices + - api.MediaDeviceInfo + - api.InputDeviceInfo + - api.CanvasCaptureMediaStreamTrack +spec-urls: + - https://w3c.github.io/mediacapture-main/ + - https://w3c.github.io/mediacapture-fromelement/ --- {{DefaultAPISidebar("Media Capture and Streams")}} @@ -30,21 +39,18 @@ In these reference articles, you'll find the fundamental information you'll need - {{domxref("MediaDeviceInfo")}} - {{domxref("MediaDevices")}} - {{domxref("MediaStream")}} -- {{domxref("MediaStreamEvent")}} - {{domxref("MediaStreamTrack")}} - {{domxref("MediaStreamTrackEvent")}} - {{domxref("MediaTrackConstraints")}} - {{domxref("MediaTrackSettings")}} - {{domxref("MediaTrackSupportedConstraints")}} - {{domxref("OverconstrainedError")}} -- {{domxref("URL")}} ## Events - {{domxref("MediaStream/addtrack_event", "addtrack")}} - {{domxref("MediaStreamTrack/ended_event", "ended")}} - {{domxref("MediaStreamTrack/mute_event", "mute")}} -- {{domxref("MediaStreamTrack.overconstrained_event", "overconstrained")}} - {{domxref("MediaStream/removetrack_event", "removetrack")}} - {{domxref("MediaStreamTrack/unmute_event", "unmute")}} @@ -61,5 +67,4 @@ The [Taking still photos with getUserMedia()](/en-US/docs/Web/API/Media_Capture_ ## See also - [WebRTC](/en-US/docs/Web/API/WebRTC_API) - the introductory page to the API -- {{domxref("mediaDevices.getUserMedia()")}} - [Taking still photos with WebRTC](/en-US/docs/Web/API/Media_Capture_and_Streams_API/Taking_still_photos): a demonstration and tutorial about using `getUserMedia()`. diff --git a/files/en-us/web/api/media_capture_and_streams_api/taking_still_photos/index.md b/files/en-us/web/api/media_capture_and_streams_api/taking_still_photos/index.md index 2993494381246a3..da2460a4b2a31fa 100644 --- a/files/en-us/web/api/media_capture_and_streams_api/taking_still_photos/index.md +++ b/files/en-us/web/api/media_capture_and_streams_api/taking_still_photos/index.md @@ -291,12 +291,12 @@ If there isn't a valid image available (that is, the `width` and `height` are bo margin-left: auto; margin-right: auto; bottom: 32px; - background-color: rgba(0, 150, 0, 0.5); - border: 1px solid rgba(255, 255, 255, 0.7); - box-shadow: 0px 0px 1px 2px rgba(0, 0, 0, 0.2); + background-color: rgb(0 150 0 / 50%); + border: 1px solid rgb(255 255 255 / 70%); + box-shadow: 0px 0px 1px 2px rgb(0 0 0 / 20%); font-size: 14px; font-family: "Lucida Grande", "Arial", sans-serif; - color: rgba(255, 255, 255, 1); + color: rgb(255 255 255 / 100%); } .contentarea { diff --git a/files/en-us/web/api/mediadeviceinfo/deviceid/index.md b/files/en-us/web/api/mediadeviceinfo/deviceid/index.md index 576bcf08c1b4976..24cc171145425b1 100644 --- a/files/en-us/web/api/mediadeviceinfo/deviceid/index.md +++ b/files/en-us/web/api/mediadeviceinfo/deviceid/index.md @@ -6,9 +6,9 @@ page-type: web-api-instance-property browser-compat: api.MediaDeviceInfo.deviceId --- -{{APIRef("Media Capture")}} +{{APIRef("Media Capture and Streams")}}{{securecontext_header}} -The **`deviceId`** readonly property +The **`deviceId`** read-only property of the {{domxref("MediaDeviceInfo")}} interface returns a string that is an identifier for the represented device and is persisted across sessions. diff --git a/files/en-us/web/api/mediadeviceinfo/groupid/index.md b/files/en-us/web/api/mediadeviceinfo/groupid/index.md index 0a52a2e092be573..4ec18345d9517cb 100644 --- a/files/en-us/web/api/mediadeviceinfo/groupid/index.md +++ b/files/en-us/web/api/mediadeviceinfo/groupid/index.md @@ -6,9 +6,9 @@ page-type: web-api-instance-property browser-compat: api.MediaDeviceInfo.groupId --- -{{APIRef("Media Capture")}} +{{APIRef("Media Capture and Streams")}}{{securecontext_header}} -The **`groupId`** readonly property of +The **`groupId`** read-only property of the {{domxref("MediaDeviceInfo")}} interface returns a string that is a group identifier. diff --git a/files/en-us/web/api/mediadeviceinfo/index.md b/files/en-us/web/api/mediadeviceinfo/index.md index 75d224771b22a95..4725fe66a8c1363 100644 --- a/files/en-us/web/api/mediadeviceinfo/index.md +++ b/files/en-us/web/api/mediadeviceinfo/index.md @@ -5,9 +5,9 @@ page-type: web-api-interface browser-compat: api.MediaDeviceInfo --- -{{APIRef("WebRTC")}} +{{APIRef("Media Capture and Streams")}}{{securecontext_header}} -The **`MediaDeviceInfo`** interface contains information that describes a single media input or output device. +The **`MediaDeviceInfo`** interface of the {{domxref("Media Capture and Streams API", "", "", "nocode")}} contains information that describes a single media input or output device. The list of devices obtained by calling {{domxref("MediaDevices.enumerateDevices", "navigator.mediaDevices.enumerateDevices()")}} is an array of `MediaDeviceInfo` objects, one per media device. diff --git a/files/en-us/web/api/mediadeviceinfo/kind/index.md b/files/en-us/web/api/mediadeviceinfo/kind/index.md index af84825ec1d11ae..6753f399dac2d95 100644 --- a/files/en-us/web/api/mediadeviceinfo/kind/index.md +++ b/files/en-us/web/api/mediadeviceinfo/kind/index.md @@ -6,15 +6,15 @@ page-type: web-api-instance-property browser-compat: api.MediaDeviceInfo.kind --- -{{APIRef("Media Capture")}} +{{APIRef("Media Capture and Streams")}}{{securecontext_header}} -The **`kind`** readonly property of +The **`kind`** read-only property of the {{domxref("MediaDeviceInfo")}} interface returns an enumerated value, that is -either "videoinput", "audioinput" or "audiooutput". +either `"videoinput"`, `"audioinput"` or `"audiooutput"`. ## Value -A string. +One of `"videoinput"`, `"audioinput"` or `"audiooutput"`. ## Specifications diff --git a/files/en-us/web/api/mediadeviceinfo/label/index.md b/files/en-us/web/api/mediadeviceinfo/label/index.md index 672525ef4e14241..f3777b11073313a 100644 --- a/files/en-us/web/api/mediadeviceinfo/label/index.md +++ b/files/en-us/web/api/mediadeviceinfo/label/index.md @@ -6,9 +6,9 @@ page-type: web-api-instance-property browser-compat: api.MediaDeviceInfo.label --- -{{APIRef("Media Capture")}} +{{APIRef("Media Capture and Streams")}}{{securecontext_header}} -The **`label`** readonly +The **`label`** read-only property of the {{domxref("MediaDeviceInfo")}} interface returns a string describing this device (for example "External USB Webcam"). diff --git a/files/en-us/web/api/mediadeviceinfo/tojson/index.md b/files/en-us/web/api/mediadeviceinfo/tojson/index.md index e7ca3ef8cdbed67..71cf17313dd7ef8 100644 --- a/files/en-us/web/api/mediadeviceinfo/tojson/index.md +++ b/files/en-us/web/api/mediadeviceinfo/tojson/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.MediaDeviceInfo.toJSON --- -{{APIRef("WebRTC")}} +{{APIRef("Media Capture and Streams")}}{{securecontext_header}} The **`toJSON()`** method of the {{domxref("MediaDeviceInfo")}} interface is a {{Glossary("Serialization","serializer")}}; it returns a JSON representation of the {{domxref("MediaDeviceInfo")}} object. diff --git a/files/en-us/web/api/mediadevices/devicechange_event/index.md b/files/en-us/web/api/mediadevices/devicechange_event/index.md index 81d8b8dbe8d264a..b46271f374bbdf4 100644 --- a/files/en-us/web/api/mediadevices/devicechange_event/index.md +++ b/files/en-us/web/api/mediadevices/devicechange_event/index.md @@ -6,9 +6,9 @@ page-type: web-api-event browser-compat: api.MediaDevices.devicechange_event --- -{{APIRef}} +{{APIRef("Media Capture and Streams")}}{{SecureContext_Header}} -A `devicechange` event is sent to a {{domxref("MediaDevices")}} instance whenever a media device such as a camera, microphone, or speaker is connected to or removed from the system. +The **`devicechange`** event is sent to a {{domxref("MediaDevices")}} instance whenever a media device such as a camera, microphone, or speaker is connected to or removed from the system. This event is not cancelable and does not bubble. diff --git a/files/en-us/web/api/mediadevices/enumeratedevices/index.md b/files/en-us/web/api/mediadevices/enumeratedevices/index.md index fa9afb9be082669..68d714b4c3a81a8 100644 --- a/files/en-us/web/api/mediadevices/enumeratedevices/index.md +++ b/files/en-us/web/api/mediadevices/enumeratedevices/index.md @@ -6,9 +6,9 @@ page-type: web-api-instance-method browser-compat: api.MediaDevices.enumerateDevices --- -{{APIRef("WebRTC")}} +{{APIRef("Media Capture and Streams")}}{{SecureContext_Header}} -The {{domxref("MediaDevices")}} method **`enumerateDevices()`** requests a list of the currently available media input and output devices, such as microphones, cameras, headsets, and so forth. +The **`enumerateDevices()`** method of the {{domxref("MediaDevices")}} interface requests a list of the currently available media input and output devices, such as microphones, cameras, headsets, and so forth. The returned {{jsxref("Promise")}} is resolved with an array of {{domxref("MediaDeviceInfo")}} objects describing the devices. The returned list will omit any devices that are blocked by the document [Permission Policy](/en-US/docs/Web/HTTP/Headers/Permissions-Policy): [`microphone`](/en-US/docs/Web/HTTP/Headers/Permissions-Policy/microphone), [`camera`](/en-US/docs/Web/HTTP/Headers/Permissions-Policy/camera), [`speaker-selection`](/en-US/docs/Web/HTTP/Headers/Permissions-Policy/speaker-selection) (for output devices), and so on. @@ -26,12 +26,14 @@ None. ### Return value -A {{ jsxref("Promise") }} that is fulfilled with an array of {{domxref("MediaDeviceInfo")}} objects. +A {{jsxref("Promise")}} that is fulfilled with an array of {{domxref("MediaDeviceInfo")}} objects. Each object in the array describes one of the available media input and output devices. The order is significant — the default capture devices will be listed first. Other than default devices, only devices for which permission has been granted are "available". +If the media device is an input device, an {{domxref("InputDeviceInfo")}} object will be returned instead. + If enumeration fails, the promise is rejected. ## Security requirements @@ -39,6 +41,7 @@ If enumeration fails, the promise is rejected. Access to the API is subject to the following constraints: - The method must be called in a [secure context](/en-US/docs/Web/Security/Secure_Contexts). +- The document must be fully active and its visibility must be "visible". ## Examples diff --git a/files/en-us/web/api/mediadevices/getdisplaymedia/index.md b/files/en-us/web/api/mediadevices/getdisplaymedia/index.md index a04fed9f681c634..67badaffcdf3267 100644 --- a/files/en-us/web/api/mediadevices/getdisplaymedia/index.md +++ b/files/en-us/web/api/mediadevices/getdisplaymedia/index.md @@ -6,9 +6,9 @@ page-type: web-api-instance-method browser-compat: api.MediaDevices.getDisplayMedia --- -{{DefaultAPISidebar("Screen Capture API")}} +{{APIRef("Screen Capture API")}}{{SecureContext_Header}} -The {{domxref("MediaDevices")}} interface's **`getDisplayMedia()`** method prompts the user to select and +The **`getDisplayMedia()`** method of the {{domxref("MediaDevices")}} interface prompts the user to select and grant permission to capture the contents of a display or portion thereof (such as a window) as a {{domxref("MediaStream")}}. The resulting stream can then be @@ -26,21 +26,31 @@ getDisplayMedia(options) ### Parameters - `options` {{optional_inline}} + - : An optional object specifying requirements for the returned {{domxref("MediaStream")}}. The options for `getDisplayMedia()` work in the same as the [constraints](/en-US/docs/Web/API/MediaDevices/getUserMedia#parameters) for the {{domxref("MediaDevices.getUserMedia()")}} method, although in that case only `audio` and `video` can be specified. The list of possible option properties for `getDisplayMedia()` is as follows: + - `video` {{optional_inline}} - : A boolean or a {{domxref("MediaTrackConstraints")}} instance; the default value is `true`. If this option is omitted or set to `true`, the stream will contain a video track A value of `true` indicates that the returned {{domxref("MediaStream")}} will contain a video track. Since `getDisplayMedia()` requires a video track, if this option is set to `false` the promise will reject with a `TypeError`. - `audio` {{optional_inline}} - : A boolean or a {{domxref("MediaTrackConstraints")}} instance; the default value is `false`. A value of `true` indicates that the returned {{domxref("MediaStream")}} will contain an audio track, if audio is supported and available for the display surface chosen by the user. - - `controller` {{optional_inline}} + - `controller` {{Experimental_Inline}} {{optional_inline}} - : A {{domxref("CaptureController")}} object instance containing methods that can be used to further manipulate the capture session if included. - - `preferCurrentTab` {{non-standard_inline}} {{optional_inline}} + - `monitorTypeSurfaces` {{optional_inline}} + + - : An enumerated value specifying whether the browser should offer entire screens in the screen capture options presented to the user alongside tab and window options. This option is intended to protect companies from leakage of private information through employee error when using video conferencing apps. Possible values are `include`, which hints that the browser should include screen options, and `exclude`, which hints that they should be excluded. A default value is not mandated by the spec; see the [Browser compatibility](#browser_compatibility) section for browser-specific defaults. + + > **Note:** You cannot set `monitorTypeSurfaces: "exclude"` at the same time as [`displaySurface: "monitor"`](/en-US/docs/Web/API/MediaTrackConstraints/displaySurface) as the two settings are contradictory. Trying to do so will result in the `getDisplayMedia()` call failing with a `TypeError`. + + - `preferCurrentTab` {{non-standard_inline}} {{Experimental_Inline}} {{optional_inline}} - : A boolean; a value of `true` instructs the browser to offer the current tab as the most prominent capture source, i.e. as a separate "This Tab" option in the "Choose what to share" options presented to the user. This is useful as many app types generally just want to share the current tab. For example, a slide deck app might want to let the user stream the current tab containing the presentation to a virtual conference. A default value is not mandated by the spec; see the [Browser compatibility](#browser_compatibility) section for browser-specific defaults. - - `selfBrowserSurface` {{optional_inline}} + - `selfBrowserSurface` {{Experimental_Inline}} {{optional_inline}} - : An enumerated value specifying whether the browser should allow the user to select the current tab for capture. This helps to avoid the "infinite hall of mirrors" effect experienced when a video conferencing app inadvertently shares its own display. Possible values are `include`, which hints that the browser should include the current tab in the choices offered for capture, and `exclude`, which hints that it should be excluded. A default value is not mandated by the spec; see the [Browser compatibility](#browser_compatibility) section for browser-specific defaults. - - `surfaceSwitching` {{optional_inline}} + - `surfaceSwitching` {{Experimental_Inline}} {{optional_inline}} - : An enumerated value specifying whether the browser should display a control to allow the user to dynamically switch the shared tab during screen-sharing. This is much more convenient than having to go through the whole sharing process again each time a user wants to switch the shared tab. Possible values are `include`, which hints that the browser should include the control, and `exclude`, which hints that it should not be shown. A default value is not mandated by the spec; see the [Browser compatibility](#browser_compatibility) section for browser-specific defaults. - - `systemAudio` {{optional_inline}} + - `systemAudio` {{Experimental_Inline}} {{optional_inline}} - : An enumerated value specifying whether the browser should include the system audio among the possible audio sources offered to the user. Possible values are `include`, which hints that the browser should include the system audio in the list of choices, and `exclude`, which hints that it should be excluded. A default value is not mandated by the spec; see the [Browser compatibility](#browser_compatibility) section for browser-specific defaults. + - `monitorTypeSurfaces` {{Experimental_Inline}} {{optional_inline}} + - : An enumerated value specifying whether the application would like the user agent to offer the user the option to choose display surfaces whose type is monitor. Possible values are `include`, which hints that the browser should include the display surfaces whose type is monitor, and `exclude`, which hints that it should be excluded. A default value is not mandated by the spec; see the [Browser compatibility](#browser_compatibility) section for browser-specific defaults. > **Note:** See the article [Capabilities, constraints, and settings](/en-US/docs/Web/API/Media_Capture_and_Streams_API/Constraints) for a lot more detail on how these options work. @@ -55,26 +65,26 @@ audio track. ### Exceptions - `AbortError` {{domxref("DOMException")}} - - : Returned if an error or failure does not match any of the other exceptions listed here. + - : Thrown if an error or failure does not match any of the other exceptions listed here. - `InvalidStateError` {{domxref("DOMException")}} - - : Returned if the call to `getDisplayMedia()` was not made from code running due to a - user action, such as an event handler. Another potential cause for this event: the - {{domxref("document")}} in whose context `getDisplayMedia()` was called is - not fully active; for example, perhaps it is not the frontmost tab. + - : Thrown if the call to `getDisplayMedia()` was not made from code running due to a + {{glossary("transient activation")}}, such as an event handler. Or if the browser context is + not fully active or does not focused. Or if the `controller` options has been already used in creating + another {{domxref("MediaStream")}}. - `NotAllowedError` {{domxref("DOMException")}} - - : Returned if the permission to access a screen area was denied by the user (for example by a [Permissions Policy](/en-US/docs/Web/HTTP/Permissions_Policy)), or the current browsing instance is not permitted access to screen sharing. + - : Thrown if the permission to access a screen area was denied by the user, or the current browsing instance is not permitted access to screen sharing (for example by a [Permissions Policy](/en-US/docs/Web/HTTP/Permissions_Policy)). - `NotFoundError` {{domxref("DOMException")}} - - : Returned if no sources of screen video are available for capture. + - : Thrown if no sources of screen video are available for capture. - `NotReadableError` {{domxref("DOMException")}} - - : Returned if the user selected a screen, window, tab, or another source of screen data, but a + - : Thrown if the user selected a screen, window, tab, or another source of screen data, but a hardware or operating system level error or lockout occurred, preventing the sharing of the selected source. - `OverconstrainedError` {{domxref("DOMException")}} - - : Returned if, after creating the stream, applying any specified constraints fails + - : Thrown if, after creating the stream, applying any specified constraints fails because no compatible stream could be generated. - {{jsxref("TypeError")}} - - : Returned if the specified `options` include values that are not permitted - when calling `getDisplayMedia()`, for example a `video` property set to false, or if any specified {{domxref("MediaTrackConstraints")}} are not permitted. `min` and `exact` values are not permitted in constraints used in {{domxref("MediaDevices.getDisplayMedia()")}} calls. + - : Thrown if the specified `options` include values that are not permitted + when calling `getDisplayMedia()`, for example a `video` property set to false, or if any specified {{domxref("MediaTrackConstraints")}} are not permitted. `min` and `exact` values are not permitted in constraints used in `getDisplayMedia()` calls. ## Security @@ -95,12 +105,25 @@ details measures browsers are required to take in order to fully support ## Examples -In the example below, a `startCapture()` method is created which initiates +In the example below a `startCapture()` method is created, which initiates screen capture given a set of options specified by the `displayMediaOptions` -parameter. The options are specified in an object which specifies the preferred stream -configuration and the [display surface](/en-US/docs/Web/API/Screen_Capture_API/Using_Screen_Capture#visible_vs_logical_display_surfaces) from which video is to be captured. +parameter. ```js +const displayMediaOptions = { + video: { + displaySurface: "browser", + }, + audio: { + suppressLocalAudioPlayback: false, + }, + preferCurrentTab: false, + selfBrowserSurface: "exclude", + systemAudio: "include", + surfaceSwitching: "include", + monitorTypeSurfaces: "include", +}; + async function startCapture(displayMediaOptions) { let captureStream; @@ -120,6 +143,8 @@ requested by the specified options. The stream is then returned to the caller fo perhaps for adding to a WebRTC call using {{domxref("RTCPeerConnection.addTrack()")}} to add the video track from the stream. +> **Note:** The [Screen sharing controls](https://screen-sharing-controls.glitch.me/) demo provides a complete implementation that allows you to create a screen capture with your choice of `getDisplayMedia()` constraints and options. + ## Specifications {{Specifications}} diff --git a/files/en-us/web/api/mediadevices/getsupportedconstraints/index.md b/files/en-us/web/api/mediadevices/getsupportedconstraints/index.md index c02bc319c77ef04..6bd44c3aec72eeb 100644 --- a/files/en-us/web/api/mediadevices/getsupportedconstraints/index.md +++ b/files/en-us/web/api/mediadevices/getsupportedconstraints/index.md @@ -6,13 +6,9 @@ page-type: web-api-instance-method browser-compat: api.MediaDevices.getSupportedConstraints --- -{{APIRef("Media Capture and Streams")}} +{{APIRef("Media Capture and Streams")}}{{SecureContext_Header}} -The -**`getSupportedConstraints()`** -method of the {{domxref("MediaDevices")}} interface returns an object based on the -{{domxref("MediaTrackSupportedConstraints")}} dictionary, whose member fields each -specify one of the constrainable properties the {{Glossary("user agent")}} understands. +The **`getSupportedConstraints()`** method of the {{domxref("MediaDevices")}} interface returns an object based on the {{domxref("MediaTrackSupportedConstraints")}} dictionary, whose member fields each specify one of the constrainable properties the {{Glossary("user agent")}} understands. ## Syntax @@ -26,10 +22,8 @@ None. ### Return value -A new object based on the {{domxref("MediaTrackSupportedConstraints")}} dictionary -listing the constraints supported by the user agent. Because only constraints supported -by the user agent are included in the list, each of these Boolean properties has the -value `true`. +A new object based on the {{domxref("MediaTrackSupportedConstraints")}} dictionary listing the constraints supported by the user agent. +Because only constraints supported by the user agent are included in the list, each of these Boolean properties has the value `true`. ## Examples diff --git a/files/en-us/web/api/mediadevices/getusermedia/index.md b/files/en-us/web/api/mediadevices/getusermedia/index.md index 9e42c1daca74657..1e8917e5eab7f21 100644 --- a/files/en-us/web/api/mediadevices/getusermedia/index.md +++ b/files/en-us/web/api/mediadevices/getusermedia/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaDevices.getUserMedia {{securecontext_header}}{{APIRef("Media Capture and Streams")}} -The {{domxref("MediaDevices")}}**`.getUserMedia()`** method prompts the user for permission to use a media input which produces a {{domxref("MediaStream")}} with tracks containing the requested types of media. +The **`getUserMedia()`** method of the {{domxref("MediaDevices")}} interface prompts the user for permission to use a media input which produces a {{domxref("MediaStream")}} with tracks containing the requested types of media. That stream can include, for example, a video track (produced by either a hardware or virtual video source such as a camera, video recording device, screen sharing service, and so forth), an audio track (similarly, produced by a physical or virtual audio source like a microphone, A/D converter, or the like), and possibly other track types. @@ -55,6 +55,10 @@ object when the requested media has successfully been obtained. and no hardware issues occurred that would cause a `NotReadableError` {{domxref("DOMException")}}, throw if some problem occurred which prevented the device from being used. +- `InvalidStateError` {{domxref("DOMException")}} + + - : Thrown if current document is not fully active. + - `NotAllowedError` {{domxref("DOMException")}} - : Thrown if one or more of the requested source devices cannot be used at this time. This will @@ -145,8 +149,7 @@ is over. ### Security -There are a number of ways security management and controls in a {{Glossary("user - agent")}} can cause `getUserMedia()` to return a security-related error. +There are a number of ways security management and controls in a {{Glossary("user agent")}} can cause `getUserMedia()` to return a security-related error. #### Permissions Policy @@ -432,13 +435,10 @@ const constraints = { ## See also -- The older {{domxref("navigator.getUserMedia()")}} legacy API -- {{domxref("mediaDevices.enumerateDevices()")}}: Listing available media devices -- [WebRTC API](/en-US/docs/Web/API/WebRTC_API) -- [Media Capture and Streams API (Media Streams)](/en-US/docs/Web/API/Media_Capture_and_Streams_API) -- [Screen Capture API](/en-US/docs/Web/API/Screen_Capture_API): Capturing - screen contents as a {{domxref("MediaStream")}} -- {{domxref("mediaDevices.getDisplayMedia()")}}: Getting a stream containing screen - contents -- [Taking webcam photos](/en-US/docs/Web/API/Media_Capture_and_Streams_API/Taking_still_photos): A tutorial on using `getUserMedia()` to take still photos - rather than video +- The older {{domxref("Navigator.getUserMedia()")}} legacy API +- {{domxref("MediaDevices.enumerateDevices()")}}: Listing available media devices +- {{domxref("WebRTC API", "", "", "nocode")}} +- {{domxref("Media Capture and Streams API", "", "", "nocode")}} +- {{domxref("Screen Capture API", "", "", "nocode")}}: Capturing screen contents as a {{domxref("MediaStream")}} +- {{domxref("MediaDevices.getDisplayMedia()")}}: Getting a stream containing screen contents +- {{domxref("Media Capture and Streams API/Taking Still Photos", "Taking webcam photos", "", "nocode")}}: A tutorial on using `getUserMedia()` to take still photos rather than video diff --git a/files/en-us/web/api/mediadevices/index.md b/files/en-us/web/api/mediadevices/index.md index 3bfe536d1d94592..9061bb4db94bda3 100644 --- a/files/en-us/web/api/mediadevices/index.md +++ b/files/en-us/web/api/mediadevices/index.md @@ -5,9 +5,9 @@ page-type: web-api-interface browser-compat: api.MediaDevices --- -{{APIRef("Media Capture and Streams")}} +{{APIRef("Media Capture and Streams")}}{{SecureContext_Header}} -The **`MediaDevices`** interface provides access to connected media input devices like cameras and microphones, as well as screen sharing. In essence, it lets you obtain access to any hardware source of media data. +The **`MediaDevices`** interface of the {{domxref("Media Capture and Streams API", "", "", "nocode")}} provides access to connected media input devices like cameras and microphones, as well as screen sharing. In essence, it lets you obtain access to any hardware source of media data. {{InheritanceDiagram}} @@ -19,13 +19,13 @@ _Inherits properties from its parent interface, {{domxref("EventTarget")}}._ _Inherits methods from its parent interface, {{domxref("EventTarget")}}._ -- {{ domxref("MediaDevices.enumerateDevices", "enumerateDevices()") }} +- {{domxref("MediaDevices.enumerateDevices", "enumerateDevices()")}} - : Obtains an array of information about the media input and output devices available on the system. - {{domxref("MediaDevices.getSupportedConstraints", "getSupportedConstraints()")}} - : Returns an object conforming to {{domxref("MediaTrackSupportedConstraints")}} indicating which constrainable properties are supported on the {{domxref("MediaStreamTrack")}} interface. See [Media Streams API](/en-US/docs/Web/API/Media_Capture_and_Streams_API/Constraints) to learn more about constraints and how to use them. - {{domxref("MediaDevices.getDisplayMedia", "getDisplayMedia()")}} - : Prompts the user to select a display or portion of a display (such as a window) to capture as a {{domxref("MediaStream")}} for sharing or recording purposes. Returns a promise that resolves to a `MediaStream`. -- {{ domxref("MediaDevices.getUserMedia", "getUserMedia()") }} +- {{domxref("MediaDevices.getUserMedia", "getUserMedia()")}} - : With the user's permission through a prompt, turns on a camera and/or a microphone on the system and provides a {{domxref("MediaStream")}} containing a video track and/or an audio track with the input. - {{domxref("MediaDevices.selectAudioOutput", "selectAudioOutput()") }} {{Experimental_Inline}} - : Prompts the user to select a specific audio output device. diff --git a/files/en-us/web/api/mediadevices/selectaudiooutput/index.md b/files/en-us/web/api/mediadevices/selectaudiooutput/index.md index c4af7eeba3e2680..6c83d53e144728c 100644 --- a/files/en-us/web/api/mediadevices/selectaudiooutput/index.md +++ b/files/en-us/web/api/mediadevices/selectaudiooutput/index.md @@ -8,11 +8,11 @@ status: browser-compat: api.MediaDevices.selectAudioOutput --- -{{APIRef("WebRTC")}} {{SeeCompatTable}} +{{APIRef("Audio Output Devices API")}}{{securecontext_header}}{{SeeCompatTable}} -The {{domxref("MediaDevices.selectAudioOutput()")}} method of the [Audio Output Devices API](/en-US/docs/Web/API/Audio_Output_Devices_API) prompts the user to select an audio output device, such as a speaker or headset. If the user selects a device, the method grants user permission to use the selected device as an audio output sink. +The **`MediaDevices.selectAudioOutput()`** method of the [Audio Output Devices API](/en-US/docs/Web/API/Audio_Output_Devices_API) prompts the user to select an audio output device, such as a speaker or headset. If the user selects a device, the method grants user permission to use the selected device as an audio output sink. -Following selection, if the device is available it can be enumerated using [`MediaDevices.enumerateDevices()`](/en-US/docs/Web/API/MediaDevices/enumerateDevices) and set as the audio output sink using [`HTMLMediaElement.setSinkId()`](/en-US/docs/Web/API/HTMLMediaElement/setSinkId). +Following selection, if the device is available it can be enumerated using {{domxref("MediaDevices.enumerateDevices()")}} and set as the audio output sink using {{domxref("HTMLMediaElement.setSinkId()")}}. On success, the returned {{jsxref("Promise")}} is resolved with a {{domxref("MediaDeviceInfo")}} describing the selected device. @@ -63,12 +63,12 @@ Access to the API is subject to the following constraints: The user has to interact with the page or a UI element for this feature to work. - Access may be gated by the [`speaker-selection`](/en-US/docs/Web/HTTP/Headers/Permissions-Policy/midi) HTTP [Permission Policy](/en-US/docs/Web/HTTP/Permissions_Policy). -The permission status can be queried using the [Permissions API](/en-US/docs/Web/API/Permissions_API) method [`navigator.permissions.query()`](/en-US/docs/Web/API/Permissions/query), passing a permission descriptor with the `speaker-selection` permission. +The permission status can be queried using the [Permissions API](/en-US/docs/Web/API/Permissions_API) method {{domxref("Permissions.query", "navigator.permissions.query()")}}, passing a permission descriptor with the `speaker-selection` permission. ## Examples Here's an example of using `selectAudioOutput()`, within a function that is triggered by a button click. -It outputs the selected [device IDs](/en-US/docs/Web/API/MediaDeviceInfo/deviceId) and labels (if available) or an error message. +It outputs the selected {{domxref("MediaDeviceInfo.deviceId", "device IDs", "", "nocode")}} and labels (if available) or an error message. ```js document.querySelector("#myButton").addEventListener("click", () => { @@ -105,6 +105,6 @@ audiooutput: Realtek Digital Output (Realtek(R) Audio) id = 0wE6fURSZ20H0N2Nbxqg ## See also -- [`HTMLMediaElement.setSinkId()`](/en-US/docs/Web/API/HTMLMediaElement/setSinkId) -- [`HTMLMediaElement.sinkId`](/en-US/docs/Web/API/HTMLMediaElement/sinkId) +- {{domxref("HTMLMediaElement.setSinkId()")}} +- {{domxref("HTMLMediaElement.sinkId")}} - [WebRTC](/en-US/docs/Web/API/WebRTC_API) - the introductory page to the API diff --git a/files/en-us/web/api/mediakeymessageevent/index.md b/files/en-us/web/api/mediakeymessageevent/index.md index bd5be84f371a788..9a50f63f1382029 100644 --- a/files/en-us/web/api/mediakeymessageevent/index.md +++ b/files/en-us/web/api/mediakeymessageevent/index.md @@ -5,7 +5,7 @@ page-type: web-api-interface browser-compat: api.MediaKeyMessageEvent --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The **`MediaKeyMessageEvent`** interface of the [Encrypted Media Extensions API](/en-US/docs/Web/API/Encrypted_Media_Extensions_API) contains the content and related data when the content decryption module generates a message for the session. diff --git a/files/en-us/web/api/mediakeymessageevent/mediakeymessageevent/index.md b/files/en-us/web/api/mediakeymessageevent/mediakeymessageevent/index.md index 6c0a037aa581147..b5a7e1e0afeb94c 100644 --- a/files/en-us/web/api/mediakeymessageevent/mediakeymessageevent/index.md +++ b/files/en-us/web/api/mediakeymessageevent/mediakeymessageevent/index.md @@ -6,7 +6,7 @@ page-type: web-api-constructor browser-compat: api.MediaKeyMessageEvent.MediaKeyMessageEvent --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The **`MediaKeyMessageEvent`** constructor creates a new {{domxref("MediaKeyMessageEvent")}} object. diff --git a/files/en-us/web/api/mediakeymessageevent/message/index.md b/files/en-us/web/api/mediakeymessageevent/message/index.md index 6804a74977eb508..117c02881e5d20d 100644 --- a/files/en-us/web/api/mediakeymessageevent/message/index.md +++ b/files/en-us/web/api/mediakeymessageevent/message/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.MediaKeyMessageEvent.message --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The **`MediaKeyMessageEvent.message`** read-only property returns an {{jsxref("ArrayBuffer")}} with a message from the content decryption module. diff --git a/files/en-us/web/api/mediakeymessageevent/messagetype/index.md b/files/en-us/web/api/mediakeymessageevent/messagetype/index.md index 178e7d4356c606a..74a170f92c1c324 100644 --- a/files/en-us/web/api/mediakeymessageevent/messagetype/index.md +++ b/files/en-us/web/api/mediakeymessageevent/messagetype/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.MediaKeyMessageEvent.messageType --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The **`MediaKeyMessageEvent.messageType`** read-only property indicates the type of message. It may be one of `license-request`, diff --git a/files/en-us/web/api/mediakeys/createsession/index.md b/files/en-us/web/api/mediakeys/createsession/index.md index c66b781fb3cd0e6..c26d61bf0671389 100644 --- a/files/en-us/web/api/mediakeys/createsession/index.md +++ b/files/en-us/web/api/mediakeys/createsession/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.MediaKeys.createSession --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The `MediaKeys.createSession()` method returns a new {{domxref("MediaKeySession")}} object, which represents a context for message exchange diff --git a/files/en-us/web/api/mediakeys/index.md b/files/en-us/web/api/mediakeys/index.md index e42c3f259467aa3..0e6a49135a3a5b4 100644 --- a/files/en-us/web/api/mediakeys/index.md +++ b/files/en-us/web/api/mediakeys/index.md @@ -5,7 +5,7 @@ page-type: web-api-interface browser-compat: api.MediaKeys --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The **`MediaKeys`** interface of [Encrypted Media Extensions API](/en-US/docs/Web/API/Encrypted_Media_Extensions_API) represents a set of keys that an associated {{domxref("HTMLMediaElement")}} can use for decryption of media data during playback. diff --git a/files/en-us/web/api/mediakeys/setservercertificate/index.md b/files/en-us/web/api/mediakeys/setservercertificate/index.md index 3b3d73faa79e2e9..9a0c3e24b10a1c5 100644 --- a/files/en-us/web/api/mediakeys/setservercertificate/index.md +++ b/files/en-us/web/api/mediakeys/setservercertificate/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.MediaKeys.setServerCertificate --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The **`MediaKeys.setServerCertificate()`** method provides a server certificate to be used to encrypt messages to the license server. diff --git a/files/en-us/web/api/mediakeysession/close/index.md b/files/en-us/web/api/mediakeysession/close/index.md index 8f6bb6000a812ca..5c6288e8fe553e9 100644 --- a/files/en-us/web/api/mediakeysession/close/index.md +++ b/files/en-us/web/api/mediakeysession/close/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.MediaKeySession.close --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The `MediaKeySession.close()` method notifies that the current media session is no longer needed, and that the content decryption module should release any resources diff --git a/files/en-us/web/api/mediakeysession/closed/index.md b/files/en-us/web/api/mediakeysession/closed/index.md index afbcc25ef00e140..a5904c2159928bf 100644 --- a/files/en-us/web/api/mediakeysession/closed/index.md +++ b/files/en-us/web/api/mediakeysession/closed/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.MediaKeySession.closed --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The `MediaKeySession.closed` read-only property returns a {{jsxref('Promise')}} signaling when a {{domxref('MediaKeySession')}} closes. This diff --git a/files/en-us/web/api/mediakeysession/expiration/index.md b/files/en-us/web/api/mediakeysession/expiration/index.md index 7cc41f4a370d9c5..bbd56386c262aaa 100644 --- a/files/en-us/web/api/mediakeysession/expiration/index.md +++ b/files/en-us/web/api/mediakeysession/expiration/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.MediaKeySession.expiration --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The **`MediaKeySession.expiration`** read-only property returns the time after which the keys in the current session can no longer be used to decrypt diff --git a/files/en-us/web/api/mediakeysession/generaterequest/index.md b/files/en-us/web/api/mediakeysession/generaterequest/index.md index fea61c7c3074f6b..94b543faa62da8e 100644 --- a/files/en-us/web/api/mediakeysession/generaterequest/index.md +++ b/files/en-us/web/api/mediakeysession/generaterequest/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.MediaKeySession.generateRequest --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The `MediaKeySession.generateRequest()` method returns a {{jsxref('Promise')}} after generating a media request based on initialization data. diff --git a/files/en-us/web/api/mediakeysession/index.md b/files/en-us/web/api/mediakeysession/index.md index 114315cd2fc02d3..9e9235b7c118339 100644 --- a/files/en-us/web/api/mediakeysession/index.md +++ b/files/en-us/web/api/mediakeysession/index.md @@ -5,7 +5,7 @@ page-type: web-api-interface browser-compat: api.MediaKeySession --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The **`MediaKeySession`** interface of the [Encrypted Media Extensions API](/en-US/docs/Web/API/Encrypted_Media_Extensions_API) represents a context for message exchange with a content decryption module (CDM). diff --git a/files/en-us/web/api/mediakeysession/keystatuses/index.md b/files/en-us/web/api/mediakeysession/keystatuses/index.md index 761dcd156cf367e..843fcf4cb3466f8 100644 --- a/files/en-us/web/api/mediakeysession/keystatuses/index.md +++ b/files/en-us/web/api/mediakeysession/keystatuses/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.MediaKeySession.keyStatuses --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The **`MediaKeySession.keyStatuses`** read-only property returns a reference to a read-only {{domxref('MediaKeyStatusMap')}} of the current diff --git a/files/en-us/web/api/mediakeysession/keystatuseschange_event/index.md b/files/en-us/web/api/mediakeysession/keystatuseschange_event/index.md index c6d4ab1138c025e..aedde65b24f1171 100644 --- a/files/en-us/web/api/mediakeysession/keystatuseschange_event/index.md +++ b/files/en-us/web/api/mediakeysession/keystatuseschange_event/index.md @@ -6,7 +6,7 @@ page-type: web-api-event browser-compat: api.MediaKeySession.keystatuseschange_event --- -{{APIRef("Encrypted Media Extensions")}} +{{APIRef("Encrypted Media Extensions")}}{{SecureContext_Header}} The **`keystatuseschange`** event of the {{domxref("MediaKeySession")}} API fires when there has been a change in the keys or their statuses within a session. diff --git a/files/en-us/web/api/mediakeysession/load/index.md b/files/en-us/web/api/mediakeysession/load/index.md index 9e0868ace75bd25..a386745c79fb5aa 100644 --- a/files/en-us/web/api/mediakeysession/load/index.md +++ b/files/en-us/web/api/mediakeysession/load/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.MediaKeySession.load --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The `MediaKeySession.load()` method returns a {{jsxref('Promise')}} that resolves to a boolean value after loading data for a specified session object. diff --git a/files/en-us/web/api/mediakeysession/message_event/index.md b/files/en-us/web/api/mediakeysession/message_event/index.md index f1ef5705ca7bb1e..d6ee7edb7e6b705 100644 --- a/files/en-us/web/api/mediakeysession/message_event/index.md +++ b/files/en-us/web/api/mediakeysession/message_event/index.md @@ -6,7 +6,7 @@ page-type: web-api-event browser-compat: api.MediaKeySession.message_event --- -{{APIRef("Encrypted Media Extensions")}} +{{APIRef("Encrypted Media Extensions")}}{{SecureContext_Header}} The **`message`** event of the {{domxref("MediaKeySession")}} interface fires when a message is generated by the diff --git a/files/en-us/web/api/mediakeysession/remove/index.md b/files/en-us/web/api/mediakeysession/remove/index.md index 4252f701789d546..e6ee8c82a0c1739 100644 --- a/files/en-us/web/api/mediakeysession/remove/index.md +++ b/files/en-us/web/api/mediakeysession/remove/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.MediaKeySession.remove --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The `MediaKeySession.remove()` method returns a {{jsxref('Promise')}} after removing any session data associated with the current object. diff --git a/files/en-us/web/api/mediakeysession/sessionid/index.md b/files/en-us/web/api/mediakeysession/sessionid/index.md index 94bd00bbd03241d..928780a80ff9c53 100644 --- a/files/en-us/web/api/mediakeysession/sessionid/index.md +++ b/files/en-us/web/api/mediakeysession/sessionid/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.MediaKeySession.sessionId --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The **`MediaKeySession.sessionId`** is a read-only property that contains a unique string generated by the content decryption module (CDM) for the diff --git a/files/en-us/web/api/mediakeysession/update/index.md b/files/en-us/web/api/mediakeysession/update/index.md index e80f72f55c623f4..e59d14299fb5ed0 100644 --- a/files/en-us/web/api/mediakeysession/update/index.md +++ b/files/en-us/web/api/mediakeysession/update/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.MediaKeySession.update --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The `MediaKeySession.update()` method loads messages and licenses to the CDM, and then returns a {{jsxref('Promise')}} . diff --git a/files/en-us/web/api/mediakeystatusmap/get/index.md b/files/en-us/web/api/mediakeystatusmap/get/index.md index 4b9480e69678307..e8437e44fa203da 100644 --- a/files/en-us/web/api/mediakeystatusmap/get/index.md +++ b/files/en-us/web/api/mediakeystatusmap/get/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.MediaKeyStatusMap.get --- -{{APIRef("EncryptedMediaExtensions API")}} +{{APIRef("EncryptedMediaExtensions API")}}{{SecureContext_Header}} The **`get`** property of the {{domxref("MediaKeyStatusMap")}} interface returns the value associated with the given diff --git a/files/en-us/web/api/mediakeystatusmap/has/index.md b/files/en-us/web/api/mediakeystatusmap/has/index.md index b283e852d733c3d..492bdc1c4d002f7 100644 --- a/files/en-us/web/api/mediakeystatusmap/has/index.md +++ b/files/en-us/web/api/mediakeystatusmap/has/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.MediaKeyStatusMap.has --- -{{APIRef("EncryptedMediaExtensions API")}} +{{APIRef("EncryptedMediaExtensions API")}}{{SecureContext_Header}} The **`has`** property of the {{domxref("MediaKeyStatusMap")}} interface returns a {{jsxref('Boolean')}}, asserting diff --git a/files/en-us/web/api/mediakeystatusmap/index.md b/files/en-us/web/api/mediakeystatusmap/index.md index 4c518ea0e9c52b4..5577f0e4abd05b9 100644 --- a/files/en-us/web/api/mediakeystatusmap/index.md +++ b/files/en-us/web/api/mediakeystatusmap/index.md @@ -5,7 +5,7 @@ page-type: web-api-interface browser-compat: api.MediaKeyStatusMap --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The **`MediaKeyStatusMap`** interface of the [Encrypted Media Extensions API](/en-US/docs/Web/API/Encrypted_Media_Extensions_API) is a read-only map of media key statuses by key IDs. diff --git a/files/en-us/web/api/mediakeystatusmap/size/index.md b/files/en-us/web/api/mediakeystatusmap/size/index.md index b268e836cb2e082..aa18a6d3f7a0ff6 100644 --- a/files/en-us/web/api/mediakeystatusmap/size/index.md +++ b/files/en-us/web/api/mediakeystatusmap/size/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.MediaKeyStatusMap.size --- -{{APIRef("EncryptedMediaExtensions API")}} +{{APIRef("EncryptedMediaExtensions API")}}{{SecureContext_Header}} The **`size`** read-only property of the {{domxref("MediaKeyStatusMap")}} interface returns the number of key/value paIrs diff --git a/files/en-us/web/api/mediakeysystemaccess/createmediakeys/index.md b/files/en-us/web/api/mediakeysystemaccess/createmediakeys/index.md index 2770f40058a8407..64315417b9ffaf7 100644 --- a/files/en-us/web/api/mediakeysystemaccess/createmediakeys/index.md +++ b/files/en-us/web/api/mediakeysystemaccess/createmediakeys/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.MediaKeySystemAccess.createMediaKeys --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The `MediaKeySystemAccess.createMediaKeys()` method returns a {{jsxref('Promise')}} that resolves to a new {{domxref('MediaKeys')}} object. diff --git a/files/en-us/web/api/mediakeysystemaccess/getconfiguration/index.md b/files/en-us/web/api/mediakeysystemaccess/getconfiguration/index.md index 96ce457d7cd93b7..26c97631d571469 100644 --- a/files/en-us/web/api/mediakeysystemaccess/getconfiguration/index.md +++ b/files/en-us/web/api/mediakeysystemaccess/getconfiguration/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-method browser-compat: api.MediaKeySystemAccess.getConfiguration --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The `MediaKeySystemAccess.getConfiguration()` method returns an object with the supported combination of the following configuration options: diff --git a/files/en-us/web/api/mediakeysystemaccess/index.md b/files/en-us/web/api/mediakeysystemaccess/index.md index e6a8288379d2629..6ca461f25b5e41f 100644 --- a/files/en-us/web/api/mediakeysystemaccess/index.md +++ b/files/en-us/web/api/mediakeysystemaccess/index.md @@ -5,7 +5,7 @@ page-type: web-api-interface browser-compat: api.MediaKeySystemAccess --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The **`MediaKeySystemAccess`** interface of the [Encrypted Media Extensions API](/en-US/docs/Web/API/Encrypted_Media_Extensions_API) provides access to a Key System for decryption and/or a content protection provider. You can request an instance of this object using the {{domxref("Navigator.requestMediaKeySystemAccess","Navigator.requestMediaKeySystemAccess()")}} method. diff --git a/files/en-us/web/api/mediakeysystemaccess/keysystem/index.md b/files/en-us/web/api/mediakeysystemaccess/keysystem/index.md index 91dbd211f58def9..045f9ff511c082c 100644 --- a/files/en-us/web/api/mediakeysystemaccess/keysystem/index.md +++ b/files/en-us/web/api/mediakeysystemaccess/keysystem/index.md @@ -6,7 +6,7 @@ page-type: web-api-instance-property browser-compat: api.MediaKeySystemAccess.keySystem --- -{{APIRef("EncryptedMediaExtensions")}} +{{APIRef("EncryptedMediaExtensions")}}{{SecureContext_Header}} The `MediaKeySystemAccess.keySystem` read-only property returns a string identifying the key system being used. diff --git a/files/en-us/web/api/mediarecorder/audiobitratemode/index.md b/files/en-us/web/api/mediarecorder/audiobitratemode/index.md new file mode 100644 index 000000000000000..20526743ed335ce --- /dev/null +++ b/files/en-us/web/api/mediarecorder/audiobitratemode/index.md @@ -0,0 +1,30 @@ +--- +title: "MediaRecorder: audioBitrateMode property" +short-title: audioBitrateMode +slug: Web/API/MediaRecorder/audioBitrateMode +page-type: web-api-instance-property +status: + - experimental +browser-compat: api.MediaRecorder.audioBitrateMode +--- + +{{APIRef("MediaStream Recording")}}{{SeeCompatTable}} + +The **`audioBitrateMode`** read-only property of the {{domxref("MediaRecorder")}} interface returns the bitrate mode used to encode audio tracks. + +## Value + +One of the following: + +- `constant` + - : The {{domxref("MediaRecorder")}} encodes at this constant bitrate. +- `variable` + - : The {{domxref("MediaRecorder")}} encodes using this variable bitrate, allowing more space to be used for complex signals and less space for less complex signals. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} diff --git a/files/en-us/web/api/mediarecorder/dataavailable_event/index.md b/files/en-us/web/api/mediarecorder/dataavailable_event/index.md index 8f3f9ce282f6e24..d0f164f3765a728 100644 --- a/files/en-us/web/api/mediarecorder/dataavailable_event/index.md +++ b/files/en-us/web/api/mediarecorder/dataavailable_event/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaRecorder.dataavailable_event {{APIRef("MediaStream Recording")}} -The `dataavailable` event is fired when the MediaRecorder delivers media +The **`dataavailable`** event of the {{domxref("MediaRecorder")}} interface is fired when the MediaRecorder delivers media data to your application for its use. The data is provided in a {{domxref("Blob")}} object that contains the data. This occurs in four situations: @@ -48,7 +48,9 @@ ondataavailable = (event) => {}; ## Event type -A generic {{domxref("Event")}}. +A {{domxref("BlobEvent")}}. Inherits from {{domxref("Event")}}. + +{{InheritanceDiagram("BlobEvent")}} ## Example @@ -60,7 +62,7 @@ mediaRecorder.onstop = (e) => { const audio = document.createElement("audio"); audio.controls = true; - const blob = new Blob(chunks, { type: "audio/ogg; codecs=opus" }); + const blob = new Blob(chunks, { type: mediaRecorder.mimeType }); const audioURL = window.URL.createObjectURL(blob); audio.src = audioURL; console.log("recorder stopped"); @@ -83,6 +85,6 @@ mediaRecorder.ondataavailable = (e) => { - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API) - [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + - getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). -- {{domxref("Navigator.getUserMedia")}} + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). +- {{domxref("Navigator.getUserMedia()")}} diff --git a/files/en-us/web/api/mediarecorder/error_event/index.md b/files/en-us/web/api/mediarecorder/error_event/index.md index f5c94a176eba12f..4f86d2040daf7c3 100644 --- a/files/en-us/web/api/mediarecorder/error_event/index.md +++ b/files/en-us/web/api/mediarecorder/error_event/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaRecorder.error_event {{APIRef("MediaStream Recording")}} -The {{domxref("MediaRecorder")}} interface's **`error`** event is fired when an error occurs: for example because recording wasn't allowed or was attempted using an unsupported codec. +The **`error`** event of the {{domxref("MediaRecorder")}} interface is fired when an error occurs: for example because recording wasn't allowed or was attempted using an unsupported codec. This event is not cancelable and does not bubble. @@ -35,26 +35,19 @@ _Inherits properties from its parent interface, {{domxref("Event")}}_. - {{domxref("MediaRecorderErrorEvent.error", "error")}} {{ReadOnlyInline}} - : A {{domxref("DOMException")}} containing information about the error that occurred. -### Value +## Description + +### Trigger A function to be called whenever an error occurs during the recorder's lifetime. In addition to other general errors that might occur, the following errors are specifically possible when using the MediaStream Recording API; to determine which occurred, check the value of {{domxref("DOMException.name", "MediaRecorderErrorEvent.error.name")}}. -- `InvalidStateError` - - : An attempt was made to stop or pause an inactive recorder, start or resume an - active recorder, or otherwise manipulate the `MediaRecorder` while in the - wrong state. This exception can also occur when a request is made on a source that has - been deleted or removed. - `SecurityError` - : The {{domxref("MediaStream")}} is configured to disallow recording. This may be the case, for example, with sources obtained using {{domxref("MediaDevices.getUserMedia", "getUserMedia()")}} when the user denies permission to use an input device. -- `NotSupportedError` - - : An attempt was made to instantiate a `MediaRecorder` using a MIME type - that isn't supported on the user's device; one or more of the requested container, - codecs, or profiles as well as other information may be invalid. - `InvalidModificationError` - : The number of tracks on the stream being recorded has changed. You can't add or remove tracks while recording media. @@ -65,13 +58,9 @@ the value of {{domxref("DOMException.name", "MediaRecorderErrorEvent.error.name" sent to the `MediaRecorder` with the remaining received data, and finally a {{domxref("MediaRecorder/stop_event", "stop")}} event is sent. -These errors may occur either directly because of a call to a -`MediaRecorder` method, or indirectly due to a problem arising during the -recording process. - ## Examples -Using [`addEventListener`](/en-US/docs/Web/API/EventTarget/addEventListener) to listen for `error` events: +Using {{domxref("EventTarget.addEventListener", "addEventListener()")}} to listen for `error` events: ```js async function record() { @@ -86,7 +75,7 @@ async function record() { record(); ``` -The same, but using the onerror event handler property: +The same, but using the `onerror` event handler property: ```js async function record() { diff --git a/files/en-us/web/api/mediarecorder/index.md b/files/en-us/web/api/mediarecorder/index.md index 520d716cbf70624..3092d32cfbdccde 100644 --- a/files/en-us/web/api/mediarecorder/index.md +++ b/files/en-us/web/api/mediarecorder/index.md @@ -28,6 +28,8 @@ The **`MediaRecorder`** interface of the [MediaStream Recording API](/en-US/docs - : Returns the video encoding bit rate in use. This may differ from the bit rate specified in the constructor (if it was provided). - {{domxref("MediaRecorder.audioBitsPerSecond")}} {{ReadOnlyInline}} - : Returns the audio encoding bit rate in use. This may differ from the bit rate specified in the constructor (if it was provided). +- {{domxref("MediaRecorder.audioBitrateMode")}} {{ReadOnlyInline}} {{Experimental_Inline}} + - : Returns the bitrate mode used to encode audio tracks. ## Static methods @@ -51,20 +53,18 @@ The **`MediaRecorder`** interface of the [MediaStream Recording API](/en-US/docs Listen to these events using `addEventListener()` or by assigning an event listener to the `oneventname` property of this interface. -- [`dataavailable`](/en-US/docs/Web/API/MediaRecorder/dataavailable_event) +- {{domxref("MediaRecorder/dataavailable_event", "dataavailable")}} - : Fires periodically each time `timeslice` milliseconds of media have been recorded (or when the entire media has been recorded, if `timeslice` wasn't specified). The event, of type {{domxref("BlobEvent")}}, contains the recorded media in its {{domxref("BlobEvent.data", "data")}} property. -- [`error`](/en-US/docs/Web/API/MediaRecorder/error_event) +- {{domxref("MediaRecorder/error_event", "error")}} - : Fired when there are fatal errors that stop recording. The received event is based on the {{domxref("MediaRecorderErrorEvent")}} interface, whose {{domxref("MediaRecorderErrorEvent.error", "error")}} property contains a {{domxref("DOMException")}} that describes the actual error that occurred. -- [`pause`](/en-US/docs/Web/API/MediaRecorder/pause_event) +- {{domxref("MediaRecorder/pause_event", "pause")}} - : Fired when media recording is paused. -- [`resume`](/en-US/docs/Web/API/MediaRecorder/resume_event) +- {{domxref("MediaRecorder/resume_event", "resume")}} - : Fired when media recording resumes after being paused. -- [`start`](/en-US/docs/Web/API/MediaRecorder/start_event) +- {{domxref("MediaRecorder/start_event", "start")}} - : Fired when media recording starts. -- [`stop`](/en-US/docs/Web/API/MediaRecorder/stop_event) +- {{domxref("MediaRecorder/stop_event", "stop")}} - : Fired when media recording ends, either when the {{domxref("MediaStream")}} ends, or after the {{domxref("MediaRecorder.stop()")}} method is called. -- [`warning`](/en-US/docs/Web/API/MediaRecorder/warning_event) {{deprecated_inline}} - - : Fired when media recording has a non-fatal error. ## Example @@ -153,8 +153,8 @@ if (navigator.mediaDevices) { ## See also - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) -- [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) - [Recording a media element](/en-US/docs/Web/API/MediaStream_Recording_API/Recording_a_media_element) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). -- {{domxref("MediaDevices.getUserMedia")}} +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). +- {{domxref("MediaDevices.getUserMedia()")}} - [OpenLang](https://github.com/chrisjohndigital/OpenLang): HTML video language lab web application using MediaDevices and the MediaStream Recording API for video recording ([source on GitHub](https://github.com/chrisjohndigital/OpenLang)) diff --git a/files/en-us/web/api/mediarecorder/istypesupported_static/index.md b/files/en-us/web/api/mediarecorder/istypesupported_static/index.md index 80ee9e13f806312..2245c7fbffbae1e 100644 --- a/files/en-us/web/api/mediarecorder/istypesupported_static/index.md +++ b/files/en-us/web/api/mediarecorder/istypesupported_static/index.md @@ -8,10 +8,7 @@ browser-compat: api.MediaRecorder.isTypeSupported_static {{APIRef("MediaStream Recording")}} -The -**`MediaRecorder.isTypeSupported()`** static method returns a -Boolean which is `true` if the MIME type specified is one the user agent -should be able to successfully record. +The **`isTypeSupported()`** static method of the {{domxref("MediaRecorder")}} interface returns a {{jsxref("Boolean")}} which is `true` if the MIME media type specified is one the user agent should be able to successfully record. ## Syntax @@ -26,11 +23,9 @@ MediaRecorder.isTypeSupported(mimeType) ### Return value -`true` if the {{domxref("MediaRecorder")}} implementation is capable of -recording {{domxref("Blob")}} objects for the specified MIME type. Recording may still -fail if there are insufficient resources to support the recording and encoding process. -If the value is `false`, the user agent is incapable of recording the -specified format. +A {{jsxref("Boolean")}}, `true` if the {{domxref("MediaRecorder")}} implementation is capable of recording {{domxref("Blob")}} objects for the specified MIME type. +Recording may still fail if there are insufficient resources to support the recording and encoding process. +If the value is `false`, the user agent is incapable of recording the specified format. ## Examples diff --git a/files/en-us/web/api/mediarecorder/mediarecorder/index.md b/files/en-us/web/api/mediarecorder/mediarecorder/index.md index 0c28207387405ad..798e33aa951afa4 100644 --- a/files/en-us/web/api/mediarecorder/mediarecorder/index.md +++ b/files/en-us/web/api/mediarecorder/mediarecorder/index.md @@ -34,7 +34,7 @@ new MediaRecorder(stream, options) - : A dictionary object that can contain the following properties: - - `mimeType` + - `mimeType` {{optional_inline}} - : A MIME type specifying the format for the resulting media; you may specify the container format (the browser will select its preferred codecs for audio and/or video), or you may [use the `codecs` parameter](/en-US/docs/Web/Media/Formats/codecs_parameter) and/or the `profiles` parameter to @@ -42,17 +42,28 @@ new MediaRecorder(stream, options) Applications can check in advance if a `mimeType` is supported by the {{Glossary("user agent")}} by calling {{domxref("MediaRecorder.isTypeSupported_static", "MediaRecorder.isTypeSupported()")}}. - - `audioBitsPerSecond` + Defaults to an empty string. + - `audioBitsPerSecond` {{optional_inline}} - : The chosen bitrate for the audio component of the media. - - `videoBitsPerSecond` + - `videoBitsPerSecond` {{optional_inline}} - : The chosen bitrate for the video component of the media. - - `bitsPerSecond` + - `bitsPerSecond` {{optional_inline}} - : The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. + - `audioBitrateMode` {{optional_inline}} + - : The bitrate mode that should be used to encode the audio. + Can be `constant`, which indicates that the recorder should encode at a constant bitrate, + or `variable`, which indicates that the recorder should encode using a variable bitrate, + thus allowing more space to be used for complex signals and less space for less-complex signals. + Defaults to `variable`. + - `videoKeyFrameIntervalDuration` {{optional_inline}} + - : The nominal interval in time between key frames in the encoded video stream. The {{glossary("user agent")}} controls key-frame generation based on this option and the `videoKeyFrameIntervalCount` option. + - `videoKeyFrameIntervalCount` {{optional_inline}} + - : The interval in number of frames between key frames in the encoded video stream. The {{glossary("user agent")}} controls key-frame generation considering this option as well as `videoKeyFrameIntervalDuration` option. > **Note:** If bits per second values are not specified for video and/or audio, the default > adopted for video is 2.5Mbps, while the audio default is adaptive, depending upon @@ -105,6 +116,6 @@ if (navigator.mediaDevices.getUserMedia) { - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) - [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + - getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). - {{domxref("MediaDevices.getUserMedia")}} diff --git a/files/en-us/web/api/mediarecorder/mimetype/index.md b/files/en-us/web/api/mediarecorder/mimetype/index.md index eef924ad60731a9..b173e1182a766d4 100644 --- a/files/en-us/web/api/mediarecorder/mimetype/index.md +++ b/files/en-us/web/api/mediarecorder/mimetype/index.md @@ -8,31 +8,23 @@ browser-compat: api.MediaRecorder.mimeType {{APIRef("MediaStream Recording")}} -The **`mimeType`** read-only -property returns the {{Glossary("MIME")}} media type that was specified when creating -the {{domxref("MediaRecorder")}} object, or, if none was specified, which was chosen -by the browser. This is the file format of the file that would result from -writing all of the recorded data to disk. - -Keep in mind that not all codecs are supported by a given container; if you write media -using a codec that is not supported by a given media container, the resulting file may -not work reliably if at all when you try to play it back. See our [media type and format guide](/en-US/docs/Web/Media/Formats) for information -about container and codec support across browsers. - -> **Note:** The term "MIME type" is officially considered to be -> historical; these strings are now officially known as **media types**. +The **`mimeType`** read-only property of the {{domxref("MediaRecorder")}} interface returns the {{Glossary("MIME")}} media type that was specified when creating the {{domxref("MediaRecorder")}} object, or, if none was specified, which was chosen by the browser. +This is the file format of the file that would result from writing all of the recorded data to disk. + +Keep in mind that not all codecs are supported by a given container; if you write media using a codec that is not supported by a given media container, the resulting file may not work reliably if at all when you try to play it back. +See our [media type and format guide](/en-US/docs/Web/Media/Formats) for information about container and codec support across browsers. + +> **Note:** The term "MIME type" is officially considered to be historical; these strings are now officially known as **media types**. > MDN Web Docs content uses the terms interchangeably. ## Value -The MIME media type which describes the format of the recorded media, as a -string. This string _may_ include the [`codecs` parameter,](/en-US/docs/Web/Media/Formats/codecs_parameter) giving details about the codecs and the codec configurations used by -the media recorder. +The MIME media type which describes the format of the recorded media, as a string. +This string _may_ include the [`codecs` parameter,](/en-US/docs/Web/Media/Formats/codecs_parameter) giving details about the codecs and the codec configurations used by the media recorder. -The media type strings are standardized by the Internet Assigned Numbers Authority -(IANA). For their official list of defined media type strings, see the article [Media Types](https://www.iana.org/assignments/media-types/media-types.xhtml) -on the IANA site. See also [media types](/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) to learn more -about media types and how they're used in web content and by web browsers. +The media type strings are standardized by the Internet Assigned Numbers Authority (IANA). +For their official list of defined media type strings, see the article [Media Types](https://www.iana.org/assignments/media-types/media-types.xhtml) on the IANA site. +See also [media types](/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) to learn more about media types and how they're used in web content and by web browsers. ## Examples @@ -63,9 +55,7 @@ if (navigator.mediaDevices) { } ``` -Changing line 14 to the following causes `MediaRecorder` to try to use AVC -Constrained Baseline Profile Level 4 for video and AAC-LC (Low Complexity) for audio, -which is good for mobile and other possible resource-constrained situations. +Changing line 14 to the following causes `MediaRecorder` to try to use AVC Constrained Baseline Profile Level 4 for video and AAC-LC (Low Complexity) for audio, which is good for mobile and other possible resource-constrained situations. ```js mimeType: 'video/mp4; codecs="avc1.424028, mp4a.40.2"'; @@ -87,7 +77,6 @@ by `m.mimeType` would then be - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) - [Codecs in common media types](/en-US/docs/Web/Media/Formats/codecs_parameter) -- [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + - getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). +- [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). - {{domxref("MediaDevices.getUserMedia()")}} diff --git a/files/en-us/web/api/mediarecorder/pause/index.md b/files/en-us/web/api/mediarecorder/pause/index.md index 876d267b6865746..0ec948475c28d27 100644 --- a/files/en-us/web/api/mediarecorder/pause/index.md +++ b/files/en-us/web/api/mediarecorder/pause/index.md @@ -8,8 +8,7 @@ browser-compat: api.MediaRecorder.pause {{APIRef("MediaStream Recording")}} -The **`MediaRecorder.pause()`** method (part -of the [MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API)) is used +The **`pause()`** method of the {{domxref("MediaRecorder")}} interface is used to pause recording of media streams. When a `MediaRecorder` object's `pause()`method is called, the @@ -65,6 +64,6 @@ pause.onclick = () => { - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) - [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + - getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). - {{domxref("Navigator.getUserMedia")}} diff --git a/files/en-us/web/api/mediarecorder/pause_event/index.md b/files/en-us/web/api/mediarecorder/pause_event/index.md index 097f737185616ab..86f1ca752ec03eb 100644 --- a/files/en-us/web/api/mediarecorder/pause_event/index.md +++ b/files/en-us/web/api/mediarecorder/pause_event/index.md @@ -8,8 +8,8 @@ browser-compat: api.MediaRecorder.pause_event {{APIRef("MediaStream Recording")}} -The `pause` event is thrown as a result of the -{{domxref("MediaRecorder.pause()")}} method being invoked. +The **`pause`** event of the {{domxref("MediaRecorder")}} interface is fired when +{{domxref("MediaRecorder.pause()")}} is called. ## Syntax @@ -49,10 +49,6 @@ mediaRecorder.onresume = () => { }; ``` -## Instance properties - -None. - ## Specifications {{Specifications}} @@ -65,6 +61,6 @@ None. - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) - [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + - getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). - {{domxref("Navigator.getUserMedia")}} diff --git a/files/en-us/web/api/mediarecorder/requestdata/index.md b/files/en-us/web/api/mediarecorder/requestdata/index.md index c32e16bf0db3760..aff6ea28f55a92d 100644 --- a/files/en-us/web/api/mediarecorder/requestdata/index.md +++ b/files/en-us/web/api/mediarecorder/requestdata/index.md @@ -8,8 +8,8 @@ browser-compat: api.MediaRecorder.requestData {{APIRef("MediaStream Recording")}} -The **`MediaRecorder.requestData()`** -method (part of the [MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API)) is used to raise a {{domxref("MediaRecorder.dataavailable_event", "dataavailable")}} event containing a +The **`requestData()`** +method of the {{domxref("MediaRecorder")}} interface is used to raise a {{domxref("MediaRecorder.dataavailable_event", "dataavailable")}} event containing a {{domxref("Blob")}} object of the captured media as it was when the method was called. This can then be grabbed and manipulated as you wish. @@ -38,12 +38,11 @@ None. None ({{jsxref("undefined")}}). -### Errors +### Exceptions -An `InvalidState` error is raised if the `requestData()` method -is called while the `MediaRecorder` object's -{{domxref("MediaRecorder.state")}} is not "recording" — the media cannot be captured if -recording is not occurring. +- `InvalidStateError` {{domxref("DOMException")}} + - : Thrown if the `MediaRecorder` is currently `"inactive"`; you cannot capture + the recording if the `MediaRecorder` is not active. ## Examples @@ -68,6 +67,6 @@ captureMedia.onclick = () => { - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) - [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + - getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). -- {{domxref("Navigator.getUserMedia")}} + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). +- {{domxref("Navigator.getUserMedia()")}} diff --git a/files/en-us/web/api/mediarecorder/resume/index.md b/files/en-us/web/api/mediarecorder/resume/index.md index b9e5b40b17f4683..2a3bb2634d700f8 100644 --- a/files/en-us/web/api/mediarecorder/resume/index.md +++ b/files/en-us/web/api/mediarecorder/resume/index.md @@ -8,15 +8,15 @@ browser-compat: api.MediaRecorder.resume {{APIRef("MediaStream Recording")}} -The **`MediaRecorder.resume()`** -method (part of the [MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API)) is used to resume media recording when it has been previously -paused. +The **`resume()`** method of the {{domxref("MediaRecorder")}} interface is used to resume media recording when it has been previously paused. + +If {{domxref("MediaRecorder.state")}} is already "recording", calling `resume()` has no effect. When the `resume()` method is invoked, the browser queues a task that runs the following steps: 1. If {{domxref("MediaRecorder.state")}} is "inactive", raise a DOM - `InvalidState` error and terminate these steps. If + `InvalidStateError` exception and terminate these steps. If {{domxref("MediaRecorder.state")}} is not "inactive", continue to the next step. 2. Set {{domxref("MediaRecorder.state")}} to "recording". 3. Continue gathering data into the current {{domxref("Blob")}}. @@ -36,13 +36,10 @@ None. None ({{jsxref("undefined")}}). -### Errors +### Exceptions -An `InvalidState` error is raised if the `resume()` method is -called while the `MediaRecorder` object's {{domxref("MediaRecorder.state")}} -is "inactive" — the recording cannot be resumed if it is not already paused; if -{{domxref("MediaRecorder.state")}} is already "recording", `resume()` has no -effect. +- `InvalidStateError` {{domxref("DOMException")}} + - : Thrown if the `MediaRecorder` is currently `"inactive"`. ## Examples @@ -70,6 +67,6 @@ pause.onclick = () => { - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) - [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + - getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). - {{domxref("Navigator.getUserMedia")}} diff --git a/files/en-us/web/api/mediarecorder/resume_event/index.md b/files/en-us/web/api/mediarecorder/resume_event/index.md index 789c16357d6d59a..00e996a25b7fbe1 100644 --- a/files/en-us/web/api/mediarecorder/resume_event/index.md +++ b/files/en-us/web/api/mediarecorder/resume_event/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaRecorder.resume_event {{APIRef("MediaStream Recording")}} -The `resume` event is thrown when +The **`resume`** event of the {{domxref("MediaRecorder")}} interface is fired when {{domxref("MediaRecorder.resume()")}} is called. ## Syntax @@ -49,10 +49,6 @@ mediaRecorder.onresume = () => { }; ``` -## Instance properties - -None. - ## Specifications {{Specifications}} @@ -65,6 +61,6 @@ None. - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) - [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + - getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). - {{domxref("Navigator.getUserMedia")}} diff --git a/files/en-us/web/api/mediarecorder/start/index.md b/files/en-us/web/api/mediarecorder/start/index.md index 0ee95c6176af95e..71ec548a511dc1b 100644 --- a/files/en-us/web/api/mediarecorder/start/index.md +++ b/files/en-us/web/api/mediarecorder/start/index.md @@ -8,9 +8,7 @@ browser-compat: api.MediaRecorder.start {{APIRef("MediaStream Recording")}} -The {{domxref("MediaRecorder")}} method -**`start()`**, which is part of the MediaStream Recording API, -begins recording media into one or more {{domxref("Blob")}} objects. +The **`start()`** method of the {{domxref("MediaRecorder")}} interface begins recording media into one or more {{domxref("Blob")}} objects. You can record the entire duration of the media into a single `Blob` (or until you @@ -65,24 +63,21 @@ are reported through {{domxref("MediaRecorder.error_event", "error")}} events se object. You can implement the {{domxref("MediaRecorder.error_event", "onerror")}} event handler to respond to these errors. -- `InvalidModificationError` {{domxref("DOMException")}} - - : Thrown if the number of tracks on the stream being recorded has changed. You cannot add or - remove tracks while recording media. - `InvalidStateError` {{domxref("DOMException")}} - : Thrown if the `MediaRecorder` is not in the `inactive` state; you cannot start recording media if it is already being recorded. See the {{domxref("MediaRecorder.state", "state")}} property. - `NotSupportedError` {{domxref("DOMException")}} - - : Thrown if the media stream you are attempting to record is inactive, or one or more of the - stream's tracks is in a format that cannot be recorded using the current configuration. + - : Thrown if: + - The media stream you are attempting to record is inactive. + - One or more of the stream's tracks is in a format that cannot be recorded using the current configuration + - The `videoKeyFrameIntervalDuration` and `videoKeyFrameIntervalCount` parameter are both specificed when creating the `MediaRecorder`. - `SecurityError` {{domxref("DOMException")}} - : Thrown if the {{domxref("MediaStream")}} is configured to disallow recording. This may be the case, for example, with sources obtained using {{domxref("MediaDevices.getUserMedia", "getUserMedia()")}} when the user denies permission to use an input device. This exception may also be delivered as an {{domxref("MediaRecorder.error_event", "error")}} event if the security options for the source media change after recording begins. -- `UnknownError` {{domxref("DOMException")}} - - : Thrown if something else went wrong during the recording process. ## Examples @@ -105,6 +100,6 @@ record.onclick = () => { - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) - [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + - getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). - {{domxref("MediaDevices.getUserMedia", "getUserMedia()")}} diff --git a/files/en-us/web/api/mediarecorder/start_event/index.md b/files/en-us/web/api/mediarecorder/start_event/index.md index 6209c1c47ed43a3..cd9eaf3138ecbdf 100644 --- a/files/en-us/web/api/mediarecorder/start_event/index.md +++ b/files/en-us/web/api/mediarecorder/start_event/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaRecorder.start_event {{APIRef("MediaStream Recording")}} -The `start` event is fired when +The **`start`** event of the {{domxref("MediaRecorder")}} interface is fired when {{domxref("MediaRecorder.start()")}} is called. At this point, the data starts being gathered into a {{domxref("Blob")}}. @@ -40,10 +40,6 @@ mediaRecorder.onstart = () => { }; ``` -## Instance properties - -None. - ## Specifications {{Specifications}} @@ -56,6 +52,6 @@ None. - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) - [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + - getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). - {{domxref("Navigator.getUserMedia")}} diff --git a/files/en-us/web/api/mediarecorder/state/index.md b/files/en-us/web/api/mediarecorder/state/index.md index d5cf860278e4feb..e47d687d2e530ae 100644 --- a/files/en-us/web/api/mediarecorder/state/index.md +++ b/files/en-us/web/api/mediarecorder/state/index.md @@ -8,18 +8,16 @@ browser-compat: api.MediaRecorder.state {{APIRef("MediaStream Recording")}} -The **`MediaRecorder.state`** read-only property returns the -current state of the current `MediaRecorder` object. +The **`state`** read-only property of the {{domxref("MediaRecorder")}} interface returns the current state of the current `MediaRecorder` object. ## Value A string containing one of the following values: - `inactive` - - : Recording is not occurring — it has either not been started yet, or it has been - started and then stopped. + - : Recording is not occurring — it has either not been started yet, or it has been started and then stopped. - `recording` - - : Recording has been started and the UA is capturing data. + - : Recording has been started and the {{glossary("user agent")}} is capturing data. - `paused` - : Recording has been started, then paused, but not yet stopped or resumed. @@ -46,6 +44,6 @@ record.onclick = () => { - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) - [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + - getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). -- {{domxref("Navigator.getUserMedia")}} + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). +- {{domxref("Navigator.getUserMedia()")}} diff --git a/files/en-us/web/api/mediarecorder/stop/index.md b/files/en-us/web/api/mediarecorder/stop/index.md index ffdf0e490baf888..0d6f3e6e59c09c0 100644 --- a/files/en-us/web/api/mediarecorder/stop/index.md +++ b/files/en-us/web/api/mediarecorder/stop/index.md @@ -8,8 +8,7 @@ browser-compat: api.MediaRecorder.stop {{APIRef("MediaStream Recording")}} -The **`MediaRecorder.stop()`** method -(part of the [MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API)) is +The **`stop()`** method of the {{domxref("MediaRecorder")}} interface is used to stop media capture. When the `stop()` method is invoked, the UA queues a task that runs the @@ -37,11 +36,11 @@ None. None ({{jsxref("undefined")}}). -### Errors +### Exceptions -An `InvalidState` error is raised if the `stop()` method is -called while the `MediaRecorder` object's {{domxref("MediaRecorder.state")}} -is "inactive" — it makes no sense to stop media capture if it is already stopped. +- `InvalidStateError` {{domxref("DOMException")}} + - : Thrown if the `MediaRecorder` is currently `"inactive"`; you cannot stop + the recording if the `MediaRecorder` is not active. ## Examples @@ -64,6 +63,6 @@ stop.onclick = () => { - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) - [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + - getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). - {{domxref("Navigator.getUserMedia")}} diff --git a/files/en-us/web/api/mediarecorder/stop_event/index.md b/files/en-us/web/api/mediarecorder/stop_event/index.md index 383b6c2e703ba5d..dea81326e244409 100644 --- a/files/en-us/web/api/mediarecorder/stop_event/index.md +++ b/files/en-us/web/api/mediarecorder/stop_event/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaRecorder.stop_event {{APIRef("MediaStream Recording")}} -The `stop` event is fired when +The **`stop`** event of the {{domxref("MediaRecorder")}} interface is fired when {{domxref("MediaRecorder.stop()")}} is called, or when the media stream being captured ends. In each case, the `stop` event is preceded by a `dataavailable` event, making the {{domxref("Blob")}} captured up to that @@ -59,6 +59,6 @@ mediaRecorder.ondataavailable = (e) => { - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) - [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + - getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). - {{domxref("Navigator.getUserMedia")}} diff --git a/files/en-us/web/api/mediarecorder/stream/index.md b/files/en-us/web/api/mediarecorder/stream/index.md index 94930151c17e92e..5282abedfc0e444 100644 --- a/files/en-us/web/api/mediarecorder/stream/index.md +++ b/files/en-us/web/api/mediarecorder/stream/index.md @@ -8,14 +8,11 @@ browser-compat: api.MediaRecorder.stream {{APIRef("MediaStream Recording")}} -The **`MediaRecorder.stream`** read-only property returns the -stream that was passed into the `MediaRecorder()` constructor when the -`MediaRecorder` was created. +The **`stream`** read-only property of the {{domxref("MediaRecorder")}} interface returns the stream that was passed into the {{domxref("MediaRecorder.MediaRecorder", "MediaRecorder()")}} constructor when the `MediaRecorder` was created. ## Value -The MediaStream passed into the `MediaRecorder()` constructor when the -`MediaRecorder` was originally created. +The {{domxref("MediaStream")}} passed into the `MediaRecorder()` constructor when the `MediaRecorder` was originally created. ## Examples @@ -51,6 +48,6 @@ if (navigator.getUserMedia) { - [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) - [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + - getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://github.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton). - {{domxref("Navigator.getUserMedia")}} diff --git a/files/en-us/web/api/mediarecorder/videobitspersecond/index.md b/files/en-us/web/api/mediarecorder/videobitspersecond/index.md index ce300d4d5aab926..3bc299e0caeab23 100644 --- a/files/en-us/web/api/mediarecorder/videobitspersecond/index.md +++ b/files/en-us/web/api/mediarecorder/videobitspersecond/index.md @@ -19,12 +19,6 @@ constructor, if it was provided. A {{jsxref("Number")}} (unsigned long). -## Example - -```js -// TBD -``` - ## Specifications {{Specifications}} diff --git a/files/en-us/web/api/mediarecorder/warning_event/index.md b/files/en-us/web/api/mediarecorder/warning_event/index.md deleted file mode 100644 index 93271e8844bf74d..000000000000000 --- a/files/en-us/web/api/mediarecorder/warning_event/index.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: "MediaRecorder: warning event" -short-title: warning -slug: Web/API/MediaRecorder/warning_event -page-type: web-api-event -status: - - deprecated -browser-compat: api.MediaRecorder.warning_event ---- - -{{APIRef("MediaStream Recording")}}{{Deprecated_Header}} - -The `warning` event fires on non-fatal errors during media recording via a `MediaRecorder`. Non-fatal errors are one's that don't halt recording. - -## Value - -A function reference. - -## Examples - -```js -mediaRecorder.onwarning = (e) => { - console.warn(`A warning has been raised: ${e.message}`); -}; -``` - -## Browser compatibility - -{{Compat}} - -## See also - -- [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) -- [Web Dictaphone](https://mdn.github.io/dom-examples/media/web-dictaphone/): MediaRecorder + getUserMedia + Web Audio API visualization demo, by [Chris Mills](https://twitter.com/chrisdavidmills) ([source on GitHub](https://github.com/mdn/dom-examples/tree/main/media/web-dictaphone).) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12). -- {{domxref("Navigator.getUserMedia")}} diff --git a/files/en-us/web/api/mediarecordererrorevent/error/index.md b/files/en-us/web/api/mediarecordererrorevent/error/index.md index aef373d4a8eac1f..0d16ce3c783348c 100644 --- a/files/en-us/web/api/mediarecordererrorevent/error/index.md +++ b/files/en-us/web/api/mediarecordererrorevent/error/index.md @@ -11,8 +11,8 @@ browser-compat: api.MediaRecorderErrorEvent.error {{APIRef("MediaStream Recording")}}{{Deprecated_Header}}{{Non-standard_Header}} -The read-only `error` property in the -**{{domxref("MediaRecorderErrorEvent")}}** interface is a +The **`error`** read-only property of the +{{domxref("MediaRecorderErrorEvent")}} interface is a {{domxref("DOMException")}} object providing details about the exception that was thrown by a {{domxref("MediaRecorder")}} instance. @@ -85,7 +85,7 @@ function recordStream(stream) { ## Specifications -{{Specifications}} +This feature is no longer part of any specification, and longer on track to become standard. ## Browser compatibility diff --git a/files/en-us/web/api/mediarecordererrorevent/index.md b/files/en-us/web/api/mediarecordererrorevent/index.md index c3723a87ed2198a..29a0d9f9a4a1eab 100644 --- a/files/en-us/web/api/mediarecordererrorevent/index.md +++ b/files/en-us/web/api/mediarecordererrorevent/index.md @@ -10,29 +10,29 @@ browser-compat: api.MediaRecorderErrorEvent {{APIRef("MediaStream Recording")}}{{Deprecated_Header}}{{Non-standard_Header}} -The `MediaRecorderErrorEvent` interface represents errors returned by the [MediaStream Recording API.](/en-US/docs/Web/API/MediaStream_Recording_API) It is an {{domxref("Event")}} object that encapsulates a reference to a {{domxref("DOMException")}} describing the error that occurred. +The **`MediaRecorderErrorEvent`** interface represents errors returned by the [MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API). It is an {{domxref("Event")}} object that encapsulates a reference to a {{domxref("DOMException")}} describing the error that occurred. {{InheritanceDiagram}} +## Constructor + +- {{domxref("MediaRecorderErrorEvent.MediaRecorderErrorEvent", "MediaStreamRecorderEvent()")}} {{Deprecated_Inline}} {{Non-standard_Inline}} + - : Creates and returns a new `MediaRecorderErrorEvent` event object with the given parameters. + ## Instance properties _Inherits properties from its parent interface, {{domxref("Event")}}_. - {{domxref("MediaRecorderErrorEvent.error", "error")}} {{ReadOnlyInline}} {{Deprecated_Inline}} {{Non-standard_Inline}} - - : A {{domxref("DOMException")}} containing information about the error that occurred. Read only. - -## Constructor - -- {{domxref("MediaRecorderErrorEvent.MediaRecorderErrorEvent", "MediaStreamRecorderEvent()")}} {{Deprecated_Inline}} {{Non-standard_Inline}} - - : Creates and returns a new `MediaRecorderErrorEvent` event object with the given parameters. + - : A {{domxref("DOMException")}} containing information about the error that occurred. ## Instance methods _Inherits methods from its parent interface, {{domxref("Event")}}_. -### Specifications +## Specifications -This feature is no longer part of any specification, and longer on track to become standard. +This feature is no longer part of any specification. ## Browser compatibility diff --git a/files/en-us/web/api/mediarecordererrorevent/mediarecordererrorevent/index.md b/files/en-us/web/api/mediarecordererrorevent/mediarecordererrorevent/index.md index 62850fff9c9e883..77ae29dfb1cd16c 100644 --- a/files/en-us/web/api/mediarecordererrorevent/mediarecordererrorevent/index.md +++ b/files/en-us/web/api/mediarecordererrorevent/mediarecordererrorevent/index.md @@ -49,7 +49,7 @@ A new {{domxref("MediaRecorderErrorEvent")}} object. ## Specifications -{{Specifications}} +This feature is no longer part of any specification, and longer on track to become standard. ## Browser compatibility diff --git a/files/en-us/web/api/mediastream/addtrack/index.md b/files/en-us/web/api/mediastream/addtrack/index.md index af099c565851522..0d7ee43f8295df3 100644 --- a/files/en-us/web/api/mediastream/addtrack/index.md +++ b/files/en-us/web/api/mediastream/addtrack/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaStream.addTrack {{APIRef("Media Capture and Streams")}} -The **`MediaStream.addTrack()`** method adds a new track to the +The **`addTrack()`** method of the {{domxref("MediaStream")}} interface adds a new track to the stream. The track is specified as a parameter of type {{domxref("MediaStreamTrack")}}. > **Note:** If the specified track is already in the stream's track set, this method has no diff --git a/files/en-us/web/api/mediastream/addtrack_event/index.md b/files/en-us/web/api/mediastream/addtrack_event/index.md index 88964f99886e6ad..570ea34599f2040 100644 --- a/files/en-us/web/api/mediastream/addtrack_event/index.md +++ b/files/en-us/web/api/mediastream/addtrack_event/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaStream.addtrack_event {{APIRef("Media Capture and Streams")}} -The `addtrack` event is fired when a new [`MediaStreamTrack`](/en-US/docs/Web/API/MediaStreamTrack) object has been added to a [`MediaStream`](/en-US/docs/Web/API/MediaStream). +The **`addtrack`** event is fired when a new [`MediaStreamTrack`](/en-US/docs/Web/API/MediaStreamTrack) object has been added to a [`MediaStream`](/en-US/docs/Web/API/MediaStream). This event is not cancelable and does not bubble. diff --git a/files/en-us/web/api/mediastream/gettrackbyid/index.md b/files/en-us/web/api/mediastream/gettrackbyid/index.md index 39332a99e138186..cd413e0030107cd 100644 --- a/files/en-us/web/api/mediastream/gettrackbyid/index.md +++ b/files/en-us/web/api/mediastream/gettrackbyid/index.md @@ -8,10 +8,9 @@ browser-compat: api.MediaStream.getTrackById {{APIRef("Media Capture and Streams")}} -The **`MediaStream.getTrackById()`** method returns a -{{domxref("MediaStreamTrack")}} object representing the track with the specified ID -string. If there is no track with the specified ID, this method returns -`null`. +The **`getTrackById()`** method of the {{domxref("MediaStream")}} interface +returns a {{domxref("MediaStreamTrack")}} object representing the track with the specified ID +string. If there is no track with the specified ID, this method returns `null`. ## Syntax diff --git a/files/en-us/web/api/mediastream/id/index.md b/files/en-us/web/api/mediastream/id/index.md index 68c5716ad63e2db..a0c9f83c8ec2d61 100644 --- a/files/en-us/web/api/mediastream/id/index.md +++ b/files/en-us/web/api/mediastream/id/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaStream.id {{APIRef("Media Capture and Streams")}} -The **`MediaStream.id`** read-only property is a +The **`id`** read-only property of the {{domxref("MediaStream")}} interface is a string containing 36 characters denoting a unique identifier (GUID) for the object. diff --git a/files/en-us/web/api/mediastream/index.md b/files/en-us/web/api/mediastream/index.md index b99d06a9001a477..fb62a3d3a41b13b 100644 --- a/files/en-us/web/api/mediastream/index.md +++ b/files/en-us/web/api/mediastream/index.md @@ -52,9 +52,9 @@ _This interface inherits methods from its parent, {{domxref("EventTarget")}}._ - : Fired when a new {{domxref("MediaStreamTrack")}} object is added. - {{domxref("MediaStream/removetrack_event", "removetrack")}} - : Fired when a {{domxref("MediaStreamTrack")}} object has been removed. -- {{domxref("MediaStream/active_event", "active")}} +- {{domxref("MediaStream/active_event", "active")}} {{Non-standard_Inline}} - : Fired when the MediaStream is activated. -- {{domxref("MediaStream/inactive_event", "inactive")}} +- {{domxref("MediaStream/inactive_event", "inactive")}} {{Non-standard_Inline}} - : Fired when the MediaStream is inactivated. ## Specifications diff --git a/files/en-us/web/api/mediastream/removetrack_event/index.md b/files/en-us/web/api/mediastream/removetrack_event/index.md index 2405e63b37815c3..c2b2f51ff5783d9 100644 --- a/files/en-us/web/api/mediastream/removetrack_event/index.md +++ b/files/en-us/web/api/mediastream/removetrack_event/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaStream.removetrack_event {{APIRef("Media Capture and Streams")}} -The `removetrack` event is fired when a new [`MediaStreamTrack`](/en-US/docs/Web/API/MediaStreamTrack) object has been removed from a [`MediaStream`](/en-US/docs/Web/API/MediaStream). +The **`removetrack`** event is fired when a new {{domxref("MediaStreamTrack")}} object has been removed from a {{domxref("MediaStream")}}. This event is not cancelable and does not bubble. diff --git a/files/en-us/web/api/mediastream_recording_api/index.md b/files/en-us/web/api/mediastream_recording_api/index.md index 8ee91484a53d35f..633cadcf5958c68 100644 --- a/files/en-us/web/api/mediastream_recording_api/index.md +++ b/files/en-us/web/api/mediastream_recording_api/index.md @@ -3,13 +3,14 @@ title: MediaStream Recording API slug: Web/API/MediaStream_Recording_API page-type: web-api-overview browser-compat: api.MediaRecorder +spec-urls: https://w3c.github.io/mediacapture-record/ --- {{DefaultAPISidebar("MediaStream Recording")}} The **MediaStream Recording API**, sometimes referred to as the _Media Recording API_ or the _MediaRecorder API_, is closely affiliated with the [Media Capture and Streams API](/en-US/docs/Web/API/Media_Capture_and_Streams_API) and the [WebRTC API](/en-US/docs/Web/API/WebRTC_API). The MediaStream Recording API makes it possible to capture the data generated by a {{domxref("MediaStream")}} or {{domxref("HTMLMediaElement")}} object for analysis, processing, or saving to disk. It's also surprisingly easy to work with. -## Basic concepts +## Concepts and usage The MediaStream Recording API is comprised of a single major interface, {{domxref("MediaRecorder")}}, which does all the work of taking the data from a {{domxref("MediaStream")}} and delivering it to you for processing. The data is delivered by a series of {{domxref("MediaRecorder.dataavailable_event", "dataavailable")}} events, already in the format you specify when creating the `MediaRecorder`. You can then process the data further or write it to file as desired. @@ -108,13 +109,13 @@ Code similar to this can be used to let the user restrict the set of devices the To learn more about using the MediaStream Recording API, see [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API), which shows how to use the API to record audio clips. A second article, [Recording a media element](/en-US/docs/Web/API/MediaStream_Recording_API/Recording_a_media_element), describes how to receive a stream from an {{HTMLElement("audio")}} or {{HTMLElement("video")}} element and use the captured stream (in this case, recording it and saving it to a local disk). -## Reference +## Interfaces - {{domxref("BlobEvent")}} - : Each time a chunk of media data is finished being recorded, it's delivered to consumers in {{domxref("Blob")}} form using a {{domxref("BlobEvent")}} of type `dataavailable`. - {{domxref("MediaRecorder")}} - : The primary interface that implements the MediaStream Recording API. -- {{domxref("MediaRecorderErrorEvent")}} +- {{domxref("MediaRecorderErrorEvent")}} {{Deprecated_Inline}} {{Non-standard_Inline}} - : The interface that represents errors thrown by the MediaStream Recording API. Its {{domxref("MediaRecorderErrorEvent.error", "error")}} property is a {{domxref("DOMException")}} that specifies that error occurred. ## Specifications @@ -127,10 +128,9 @@ To learn more about using the MediaStream Recording API, see [Using the MediaStr ## See also -- [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) -- [Recording a media element](/en-US/docs/Web/API/MediaStream_Recording_API/Recording_a_media_element) -- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://twitter.com/sw12) -- {{domxref("MediaDevices.getUserMedia")}} +- [Media Capture and Streams API](/en-US/docs/Web/API/Media_Capture_and_Streams_API) landing page +- {{domxref("MediaDevices.getUserMedia()")}} +- [simpl.info MediaStream Recording demo](https://simpl.info/mediarecorder/), by [Sam Dutton](https://github.com/samdutton) - [HTML5's Media Recorder API in Action on Chrome and Firefox](https://blog.addpipe.com/mediarecorder-api/) - [MediaRecorder polyfill](https://github.com/ai/audio-recorder-polyfill) for Safari and Edge - [TutorRoom](https://github.com/chrisjohndigital/TutorRoom): HTML video capture/playback/download using getUserMedia and the MediaStream Recording API ([source on GitHub](https://github.com/chrisjohndigital/TutorRoom)) diff --git a/files/en-us/web/api/mediastream_recording_api/recording_a_media_element/index.md b/files/en-us/web/api/mediastream_recording_api/recording_a_media_element/index.md index aa03768ecc933be..9d6afa855bf6fdd 100644 --- a/files/en-us/web/api/mediastream_recording_api/recording_a_media_element/index.md +++ b/files/en-us/web/api/mediastream_recording_api/recording_a_media_element/index.md @@ -288,6 +288,5 @@ You can {{LiveSampleLink("Example_of_recording_a_media_element", "view the full ## See also -- [MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API) -- [Using the MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API/Using_the_MediaStream_Recording_API) -- [Media Capture and Streams API](/en-US/docs/Web/API/Media_Capture_and_Streams_API) +- [Media Capture and Streams API](/en-US/docs/Web/API/Media_Capture_and_Streams_API) landing page +- {{domxref("MediaDevices.getUserMedia()")}} diff --git a/files/en-us/web/api/mediastream_recording_api/using_the_mediastream_recording_api/index.md b/files/en-us/web/api/mediastream_recording_api/using_the_mediastream_recording_api/index.md index 1863a61da1f95ba..81c9afb6ac33123 100644 --- a/files/en-us/web/api/mediastream_recording_api/using_the_mediastream_recording_api/index.md +++ b/files/en-us/web/api/mediastream_recording_api/using_the_mediastream_recording_api/index.md @@ -44,8 +44,8 @@ However, we wanted to make the third area (which contains the recorded samples y ```css .sound-clips { - box-shadow: inset 0 3px 4px rgba(0, 0, 0, 0.7); - background-color: rgba(0, 0, 0, 0.1); + box-shadow: inset 0 3px 4px rgb(0 0 0 / 70%); + background-color: rgb(0 0 0 / 10%); height: calc(100% - 240px - 0.7rem); overflow: scroll; } @@ -91,8 +91,8 @@ aside { background-color: #999; background-image: linear-gradient( to top right, - rgba(0, 0, 0, 0), - rgba(0, 0, 0, 0.5) + rgb(0 0 0 / 0%), + rgb(0 0 0 / 50%) ); } ``` @@ -263,6 +263,5 @@ Finally, we set an `onclick` handler on the delete button to be a function that ## See also -- [MediaStream Recording API](/en-US/docs/Web/API/MediaStream_Recording_API) landing page -- {{domxref("Navigator.getUserMedia()")}} -- [MediaRecorder API now supported by 65% of your website users](https://blog.addpipe.com/media-recorder-api-is-now-supported-by-65-of-all-desktop-internet-users/) +- [Media Capture and Streams API](/en-US/docs/Web/API/Media_Capture_and_Streams_API) landing page +- {{domxref("MediaDevices.getUserMedia()")}} diff --git a/files/en-us/web/api/mediastreamtrack/contenthint/index.md b/files/en-us/web/api/mediastreamtrack/contenthint/index.md index 20f3b81fa7aece1..2851775a77ff9a5 100644 --- a/files/en-us/web/api/mediastreamtrack/contenthint/index.md +++ b/files/en-us/web/api/mediastreamtrack/contenthint/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaStreamTrack.contentHint {{APIRef("Media Capture and Streams")}} -The **`MediaStreamTrack.contentHint`** property is a string that hints at the type of content the track contains. Allowable values depend on the value of the {{domxref("MediaStreamTrack.kind")}} property. +The **`contentHint`** property of the {{domxref("MediaStreamTrack")}} interface is a string that hints at the type of content the track contains. Allowable values depend on the value of the {{domxref("MediaStreamTrack.kind")}} property. ## Value diff --git a/files/en-us/web/api/mediastreamtrack/enabled/index.md b/files/en-us/web/api/mediastreamtrack/enabled/index.md index 21de37a65a5aafc..b2b364dd2d0ce45 100644 --- a/files/en-us/web/api/mediastreamtrack/enabled/index.md +++ b/files/en-us/web/api/mediastreamtrack/enabled/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaStreamTrack.enabled {{APIRef("Media Capture and Streams")}} -The **`enabled`** property on the +The **`enabled`** property of the {{domxref("MediaStreamTrack")}} interface is a Boolean value which is `true` if the track is allowed to render the source stream or `false` if it is not. This can be used to intentionally mute a diff --git a/files/en-us/web/api/mediastreamtrack/getcapabilities/index.md b/files/en-us/web/api/mediastreamtrack/getcapabilities/index.md index 9e055a296a424a7..a9fc11ab83fd31e 100644 --- a/files/en-us/web/api/mediastreamtrack/getcapabilities/index.md +++ b/files/en-us/web/api/mediastreamtrack/getcapabilities/index.md @@ -10,9 +10,8 @@ browser-compat: api.MediaStreamTrack.getCapabilities The **`getCapabilities()`** method of the {{domxref("MediaStreamTrack")}} interface returns a -{{domxref('MediaTrackCapabilities')}} object which specifies the values or range of -values which each constrainable property, based upon the platform and {{Glossary("user - agent")}}. +`MediaTrackCapabilities` object which specifies the values or range of +values which each constrainable property, based upon the platform and {{Glossary("user agent")}}. Once you know what the browser's capabilities are, your script can use {{domxref("MediaStreamTrack.applyConstraints", "applyConstraints()")}} to ask for the @@ -30,7 +29,41 @@ None. ### Return value -A {{domxref('MediaTrackCapabilities')}} object which specifies the value or range of values which are supported for each of the user agent's supported constrainable properties. +A `MediaTrackCapabilities` object which specifies the value or range of values which are supported for each of the user agent's supported constrainable properties, containing the following members: + +- `deviceId` + - : A [`ConstrainDOMString`](/en-US/docs/Web/API/MediaTrackConstraints#constraindomstring) object containing the device ID. +- `groupId` + - : A [`ConstrainDOMString`](/en-US/docs/Web/API/MediaTrackConstraints#constraindomstring) object containing a group ID. +- `autoGainControl` + - : A [`ConstrainBoolean`](/en-US/docs/Web/API/MediaTrackConstraints#constrainboolean) object reporting if the source can do auto gain control. + If the feature can be controlled by a script the source will report both true and false as possible values. +- `channelCount` + - : A [`ConstrainULong`](/en-US/docs/Web/API/MediaTrackConstraints#constrainulong) containing the channel count or range of channel counts. +- `echoCancellation` + - : A [`ConstrainBoolean`](/en-US/docs/Web/API/MediaTrackConstraints#constrainboolean) object reporting if the source can do echo cancellation. + If the feature can be controlled by a script the source will report both true and false as possible values. +- `latency` + - : A [`ConstrainDouble`](/en-US/docs/Web/API/MediaTrackConstraints#constraindouble) containing the latency or range of latencies. +- `noiseSuppression` + - : A [`ConstrainBoolean`](/en-US/docs/Web/API/MediaTrackConstraints#constrainboolean) object reporting if the source can do noise suppression. + If the feature can be controlled by a script the source will report both true and false as possible values. +- `sampleRate` + - : A [`ConstrainULong`](/en-US/docs/Web/API/MediaTrackConstraints#constrainulong) containing the sample rate or range of sample rates. +- `sampleSize` + - : A [`ConstrainULong`](/en-US/docs/Web/API/MediaTrackConstraints#constrainulong) containing the sample size or range of sample sizes. +- `aspectRatio` + - : A [`ConstrainDouble`](/en-US/docs/Web/API/MediaTrackConstraints#constraindouble) containing the video aspect ratio (width in pixels divided by height in pixels) or range of aspect ratios. +- `facingMode` + - : A [`ConstrainDOMString`](/en-US/docs/Web/API/MediaTrackConstraints#constraindomstring) object containing the camera facing mode. A camera may report multiple facings, for example "left" and "user". +- `frameRate` + - : A [`ConstrainDouble`](/en-US/docs/Web/API/MediaTrackConstraints#constraindouble) containing the frame rate or range of frame rates which are acceptable. +- `height` + - : A [`ConstrainULong`](/en-US/docs/Web/API/MediaTrackConstraints#constrainulong) containing the video height or range of heights in pixels. +- `width` + - : A [`ConstrainULong`](/en-US/docs/Web/API/MediaTrackConstraints#constrainulong) containing the video width or range of widths in pixels. +- `resizeMode` + - : A [`ConstrainDOMString`](/en-US/docs/Web/API/MediaTrackConstraints#constraindomstring) object containing the mode or an array of modes the UA can use to derive the resolution of the video track. ## Specifications @@ -39,3 +72,7 @@ A {{domxref('MediaTrackCapabilities')}} object which specifies the value or rang ## Browser compatibility {{Compat}} + +## See also + +- {{domxref("InputDeviceInfo.getCapabilities()")}}, which also return a `MediaTrackCapabilities` object. diff --git a/files/en-us/web/api/mediastreamtrack/id/index.md b/files/en-us/web/api/mediastreamtrack/id/index.md index ac519b24d188bd5..02ec7b86b9ab105 100644 --- a/files/en-us/web/api/mediastreamtrack/id/index.md +++ b/files/en-us/web/api/mediastreamtrack/id/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaStreamTrack.id {{APIRef("Media Capture and Streams")}} -The **`MediaStreamTrack.id`** read-only property returns a +The **`id`** read-only property of the {{domxref("MediaStreamTrack")}} interface returns a string containing a unique identifier (GUID) for the track, which is generated by the {{glossary("user agent")}}. diff --git a/files/en-us/web/api/mediastreamtrack/index.md b/files/en-us/web/api/mediastreamtrack/index.md index fd28f7c59bfb2f3..bebe6a44572336a 100644 --- a/files/en-us/web/api/mediastreamtrack/index.md +++ b/files/en-us/web/api/mediastreamtrack/index.md @@ -67,8 +67,6 @@ Listen to these events using {{domxref("EventTarget.addEventListener", "addEvent - : Sent when playback of the track ends (when the value {{domxref("MediaStreamTrack.readyState", "readyState")}} changes to `ended`). - {{domxref("MediaStreamTrack/mute_event", "mute")}} - : Sent to the `MediaStreamTrack` when the value of the {{domxref("MediaStreamTrack.muted", "muted")}} property is changed to `true`, indicating that the track is unable to provide data temporarily (such as when the network is experiencing a service malfunction). -- {{domxref("MediaStreamTrack/overconstrained_event", "overconstrained")}} {{Deprecated_Inline}} {{Non-standard_Inline}} - - : Sent when the constraints specified for the track cause the track to be incompatible and therefore to not be used. - {{domxref("MediaStreamTrack/unmute_event", "unmute")}} - : Sent to the track when data becomes available again, ending the `muted` state. diff --git a/files/en-us/web/api/mediastreamtrack/kind/index.md b/files/en-us/web/api/mediastreamtrack/kind/index.md index 1fc9fb0650362dc..6e78d4eb0252bd8 100644 --- a/files/en-us/web/api/mediastreamtrack/kind/index.md +++ b/files/en-us/web/api/mediastreamtrack/kind/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaStreamTrack.kind {{APIRef("Media Capture and Streams")}} -The **`MediaStreamTrack.kind`** read-only property returns a string set to `"audio"` if the track is an audio track and to `"video"`, if it is a video track. +The **`kind`** read-only property of the {{domxref("MediaStreamTrack")}} interface returns a string set to `"audio"` if the track is an audio track and to `"video"` if it is a video track. It doesn't change if the track is disassociated from its source. ## Value diff --git a/files/en-us/web/api/mediastreamtrack/label/index.md b/files/en-us/web/api/mediastreamtrack/label/index.md index 07d8ae2a3ad4fa5..a4421b17a0b7837 100644 --- a/files/en-us/web/api/mediastreamtrack/label/index.md +++ b/files/en-us/web/api/mediastreamtrack/label/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaStreamTrack.label {{APIRef("Media Capture and Streams")}} -The **`MediaStreamTrack.label`** read-only property returns a string containing a {{glossary("user agent")}}-assigned label that identifies the track source, as in `"internal microphone"`. +The **`label`** read-only property of the {{domxref("MediaStreamTrack")}} interface returns a string containing a {{glossary("user agent")}}-assigned label that identifies the track source, as in `"internal microphone"`. The string may be left empty and is empty as long as no source has been connected. When the track is disassociated from its source, the label is not changed. diff --git a/files/en-us/web/api/mediastreamtrack/overconstrained_event/index.md b/files/en-us/web/api/mediastreamtrack/overconstrained_event/index.md deleted file mode 100644 index d46b26927b0955d..000000000000000 --- a/files/en-us/web/api/mediastreamtrack/overconstrained_event/index.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -title: "MediaStreamTrack: overconstrained event" -short-title: overconstrained -slug: Web/API/MediaStreamTrack/overconstrained_event -page-type: web-api-event -status: - - deprecated - - non-standard -browser-compat: api.MediaStreamTrack.overconstrained_event ---- - -{{APIRef("Media Capture and Streams")}}{{Deprecated_Header}}{{Non-standard_Header}} - -The **`overconstrained`** event fires when the track has too many conflicting constraints. - -## Syntax - -Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property. - -```js -addEventListener("overconstrained", (event) => {}); - -onoverconstrained = (event) => {}; -``` - -## Event type - -A generic {{domxref("Event")}}. - -## Example - -```js -dc.onoverconstrained = () => console.log("overconstrained event detected!"); -``` - -## Browser compatibility - -{{Compat}} diff --git a/files/en-us/web/api/mediastreamtrack/readystate/index.md b/files/en-us/web/api/mediastreamtrack/readystate/index.md index 2c6d5493be4d08e..a5e57528b02bb93 100644 --- a/files/en-us/web/api/mediastreamtrack/readystate/index.md +++ b/files/en-us/web/api/mediastreamtrack/readystate/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaStreamTrack.readyState {{APIRef("Media Capture and Streams")}} -The **`MediaStreamTrack.readyState`** read-only property returns an enumerated value giving the status of the track. +The **`readyState`** read-only property of the {{domxref("MediaStreamTrack")}} interface returns an enumerated value giving the status of the track. ## Value diff --git a/files/en-us/web/api/mediastreamtrack/stop/index.md b/files/en-us/web/api/mediastreamtrack/stop/index.md index 804055b60c1fabe..4f67d51e2be1758 100644 --- a/files/en-us/web/api/mediastreamtrack/stop/index.md +++ b/files/en-us/web/api/mediastreamtrack/stop/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaStreamTrack.stop {{APIRef("Media Capture and Streams")}} -The **`MediaStreamTrack.stop()`** method stops the track. +The **`stop()`** method of the {{domxref("MediaStreamTrack")}} interface stops the track. ## Syntax diff --git a/files/en-us/web/api/mediastreamtrackevent/index.md b/files/en-us/web/api/mediastreamtrackevent/index.md index e2733170509167f..a19302d1066b01f 100644 --- a/files/en-us/web/api/mediastreamtrackevent/index.md +++ b/files/en-us/web/api/mediastreamtrackevent/index.md @@ -7,12 +7,17 @@ browser-compat: api.MediaStreamTrackEvent {{APIRef("Media Capture and Streams")}} -The **`MediaStreamTrackEvent`** interface represents events which indicate that a {{domxref("MediaStream")}} has had tracks added to or removed from the stream through calls to [Media Capture and Streams API](/en-US/docs/Web/API/Media_Capture_and_Streams_API) methods. These events are sent to the stream when these changes occur. +The **`MediaStreamTrackEvent`** interface of the {{domxref("Media Capture and Streams API", "", "", "nocode")}} represents events which indicate that a {{domxref("MediaStream")}} has had tracks added to or removed from the stream through calls to [Media Capture and Streams API](/en-US/docs/Web/API/Media_Capture_and_Streams_API) methods. These events are sent to the stream when these changes occur. {{InheritanceDiagram}} The events based on this interface are {{domxref("MediaStream/addtrack_event", "addtrack")}} and {{domxref("MediaStream/removetrack_event", "removetrack")}}. +## Constructor + +- {{domxref("MediaStreamTrackEvent.MediaStreamTrackEvent", "MediaStreamTrackEvent()")}} + - : Constructs a new `MediaStreamTrackEvent` with the specified configuration. + ## Instance properties _Also inherits properties from its parent interface, {{domxref("Event")}}._ @@ -20,14 +25,9 @@ _Also inherits properties from its parent interface, {{domxref("Event")}}._ - {{domxref("MediaStreamTrackEvent.track")}} {{ReadOnlyInline}} - : Returns a {{domxref("MediaStreamTrack")}} object representing the track associated with the event. -## Constructor - -- {{domxref("MediaStreamTrackEvent.MediaStreamTrackEvent", "MediaStreamTrackEvent()")}} - - : Constructs a new `MediaStreamTrackEvent` with the specified configuration. - ## Instance methods -_Also inherits methods from its parent {{domxref("Event")}}._ +_Also inherits methods from its parent interface, {{domxref("Event")}}._ ## Specifications diff --git a/files/en-us/web/api/mediastreamtrackevent/track/index.md b/files/en-us/web/api/mediastreamtrackevent/track/index.md index 8cc2e5ab8bc84b4..4d18ae164fcb7fe 100644 --- a/files/en-us/web/api/mediastreamtrackevent/track/index.md +++ b/files/en-us/web/api/mediastreamtrackevent/track/index.md @@ -8,7 +8,7 @@ browser-compat: api.MediaStreamTrackEvent.track {{APIRef("Media Capture and Streams")}} -The **`track`** read-only property of the {{domxref("MediaStreamTrackEvent")}} interface returns the {{domxref("MediaStreamTrack")}} associated with this event +The **`track`** read-only property of the {{domxref("MediaStreamTrackEvent")}} interface returns the {{domxref("MediaStreamTrack")}} associated with this event. ## Value diff --git a/files/en-us/web/api/mediatrackconstraints/displaysurface/index.md b/files/en-us/web/api/mediatrackconstraints/displaysurface/index.md index 0add7c13f5a694a..8474b2aefc31e25 100644 --- a/files/en-us/web/api/mediatrackconstraints/displaysurface/index.md +++ b/files/en-us/web/api/mediatrackconstraints/displaysurface/index.md @@ -21,6 +21,8 @@ This value _does not_ add or remove display sources in the browser's user interf See [how constraints are defined](/en-US/docs/Web/API/Media_Capture_and_Streams_API/Constraints#how_constraints_are_defined). +> **Note:** You cannot set [`monitorTypeSurfaces: "exclude"`](/en-US/docs/Web/API/MediaDevices/getDisplayMedia#monitortypesurfaces) at the same time as `displaySurface: "monitor"` as the two settings are contradictory. Trying to do so will result in the associated `getDisplayMedia()` call failing with a `TypeError`. + ## Usage notes You can check the setting selected by the user agent after the display media has been diff --git a/files/en-us/web/api/merchantvalidationevent/index.md b/files/en-us/web/api/merchantvalidationevent/index.md index 9f953df8978f7fe..649e348d4381206 100644 --- a/files/en-us/web/api/merchantvalidationevent/index.md +++ b/files/en-us/web/api/merchantvalidationevent/index.md @@ -15,19 +15,19 @@ Learn more about [merchant validation](/en-US/docs/Web/API/Payment_Request_API/C ## Constructor -- {{domxref("MerchantValidationEvent.MerchantValidationEvent()","MerchantValidationEvent()")}} {{SecureContext_Inline}} {{Deprecated_Inline}} +- {{domxref("MerchantValidationEvent.MerchantValidationEvent()","MerchantValidationEvent()")}} {{Deprecated_Inline}} - : Creates a new `MerchantValidationEvent` object describing a {{domxref("PaymentRequest.merchantvalidation_event", "merchantvalidation")}} event that will be sent to the payment handler to request that it validate the merchant. ## Instance properties -- {{domxref("MerchantValidationEvent.methodName")}} {{SecureContext_Inline}} {{Deprecated_Inline}} +- {{domxref("MerchantValidationEvent.methodName")}} {{Deprecated_Inline}} - : A string providing a unique payment method identifier for the payment handler that's requiring validation. This may be either one of the standard payment method identifier strings or a URL that both identifies and handles requests for the payment handler, such as `https://apple.com/apple-pay`. -- {{domxref("MerchantValidationEvent.validationURL")}} {{SecureContext_Inline}} {{Deprecated_Inline}} +- {{domxref("MerchantValidationEvent.validationURL")}} {{Deprecated_Inline}} - : A string specifying a URL from which the site or app can fetch payment handler specific validation information. Once this data is retrieved, the data (or a promise resolving to the validation data) should be passed into {{domxref("MerchantValidationEvent.complete", "complete()")}} to validate that the payment request is coming from an authorized merchant. ## Instance methods -- {{domxref("MerchantValidationEvent.complete()")}} {{SecureContext_Inline}} {{Deprecated_Inline}} +- {{domxref("MerchantValidationEvent.complete()")}} {{Deprecated_Inline}} - : Pass the data retrieved from the URL specified by {{domxref("MerchantValidationEvent.validationURL", "validationURL")}} into `complete()` to complete the validation process for the {{domxref("PaymentRequest")}}. ## Browser compatibility diff --git a/files/en-us/web/api/messagechannel/index.md b/files/en-us/web/api/messagechannel/index.md index ee18b3e35a9b70b..9ed1a480fc7ca9d 100644 --- a/files/en-us/web/api/messagechannel/index.md +++ b/files/en-us/web/api/messagechannel/index.md @@ -5,12 +5,17 @@ page-type: web-api-interface browser-compat: api.MessageChannel --- -{{APIRef("HTML DOM")}} +{{APIRef("Channel Messaging API")}} The **`MessageChannel`** interface of the [Channel Messaging API](/en-US/docs/Web/API/Channel_Messaging_API) allows us to create a new message channel and send data through it via its two {{domxref("MessagePort")}} properties. {{AvailableInWorkers}} +## Constructor + +- {{domxref("MessageChannel.MessageChannel", "MessageChannel()")}} + - : Returns a new `MessageChannel` object with two new {{domxref("MessagePort")}} objects. + ## Instance properties - {{domxref("MessageChannel.port1")}} {{ReadOnlyInline}} @@ -18,16 +23,11 @@ The **`MessageChannel`** interface of the [Channel Messaging API](/en-US/docs/We - {{domxref("MessageChannel.port2")}} {{ReadOnlyInline}} - : Returns port2 of the channel. -## Constructor - -- {{domxref("MessageChannel.MessageChannel", "MessageChannel()")}} - - : Returns a new `MessageChannel` object with two new {{domxref("MessagePort")}} objects. - ## Example -In the following example, you can see a new channel being created using the {{domxref("MessageChannel()", "MessageChannel.MessageChannel")}} constructor. +In the following example, you can see a new channel being created using the {{domxref("MessageChannel.MessageChannel", "MessageChannel()")}} constructor. -When the IFrame has loaded, we register an `onmessage` handler for {{domxref("MessageChannel.port1")}} and transfer {{domxref("MessageChannel.port2")}} to the IFrame using the {{domxref("window.postMessage")}} method along with a message. +When the IFrame has loaded, we register an {{domxref("MessagePort/message_event","onmessage")}} handler for {{domxref("MessageChannel.port1")}} and transfer {{domxref("MessageChannel.port2")}} to the IFrame using the {{domxref("window.postMessage")}} method along with a message. When a message is received back from the IFrame, the `onMessage` function outputs the message to a paragraph. diff --git a/files/en-us/web/api/messagechannel/messagechannel/index.md b/files/en-us/web/api/messagechannel/messagechannel/index.md index 18d757ae60c3730..2e9fd7a3b5d8bd0 100644 --- a/files/en-us/web/api/messagechannel/messagechannel/index.md +++ b/files/en-us/web/api/messagechannel/messagechannel/index.md @@ -6,9 +6,9 @@ page-type: web-api-constructor browser-compat: api.MessageChannel.MessageChannel --- -{{APIRef("HTML DOM")}} +{{APIRef("Channel Messaging API")}} -The `MessageChannel()` constructor of the {{domxref("MessageChannel")}} +The **`MessageChannel()`** constructor of the {{domxref("MessageChannel")}} interface returns a new {{domxref("MessageChannel")}} object with two new {{domxref("MessagePort")}} objects. @@ -31,9 +31,9 @@ A new {{domxref("MessageChannel")}} object. ## Examples In the following code block, you can see a new channel being created using the -{{domxref("MessageChannel()", "MessageChannel.MessageChannel")}} constructor. +`MessageChannel()` constructor. When the {{HTMLElement("iframe")}} has loaded, -we pass `port2` to the ` + ``` + + - If using `create()`: + + ```html + + ``` + + The ` +... + ``` The `load` event fires when the eagerly-loaded content has all been loaded. At that time, it's entirely possible (or even likely) that there may be lazily-loaded images or iframes within the {{Glossary("visual viewport")}} that haven't yet loaded. diff --git a/files/en-us/web/privacy/index.md b/files/en-us/web/privacy/index.md index 6a4c59dbfd542df..e0547c1f0cf536b 100644 --- a/files/en-us/web/privacy/index.md +++ b/files/en-us/web/privacy/index.md @@ -125,8 +125,8 @@ Some of the most developed parts of the privacy sandbox project are as follows: - [Cookies Having Independent Partitioned State (CHIPS)](/en-US/docs/Web/Privacy/Partitioned_cookies) - : Also known as **partitioned cookies**, CHIPs allows developers to opt a cookie into partitioned storage, with a separate cookie jar per top-level site. -- [First-party sets](https://developer.chrome.com/docs/privacy-sandbox/first-party-sets/) - - : A mechanism for a company to declare relationships between different origins. Supporting browsers will then allow limited third-party cookie access across those origins for specific purposes. +- [Related website sets](/en-US/docs/Web/API/Storage_Access_API/Related_website_sets) + - : A mechanism for a company to declare relationships between different sites. Supporting browsers will then allow limited third-party cookie access across those sites for specific purposes, via the [Storage Access API](/en-US/docs/Web/API/Storage_Access_API). - Third-party cookie default - : Chrome does not yet block third-party cookies by default, but this can be set by users in Chrome settings. @@ -203,7 +203,7 @@ Earlier on we discussed tracking, and some of the unethical purposes they are us Also recall from earlier that browsers are implementing a number of technologies to limit the usage of tracking cookies, especially cross-site cookies, with the eventual aim of removing them altogether. It is a good idea to prepare for this, by limiting the amount of tracking activities you rely on, and/or implementing desired information persistence in other ways. For example: - Use an alternative client-side storage mechanism such as [Web Storage](/en-US/docs/Web/API/Web_Storage_API) to persist data. This does have the downside that the data is stored per-origin, so it can't be shared. -- Use a technology such as [IFrame credentialless](/en-US/docs/Web/Security/IFrame_credentialless), [First-party sets](https://developer.chrome.com/docs/privacy-sandbox/first-party-sets/) and/or the [Storage access API](/en-US/docs/Web/API/Storage_Access_API) to allow your sites to opt in to using cross-site cookies in a safe, controlled way, or block them altogether. These currently have limited browser support. +- Use a technology such as the [Storage Access API](/en-US/docs/Web/API/Storage_Access_API) to allow your sites to opt-in to using cross-site cookies in a safe and controlled way. - Use a server-side solution for data persistence. > **Note:** To reiterate what we said earlier, make sure you clearly communicate to your users what you are doing via your privacy policy, allow them to opt-in, and easily delete their data if they change their mind at a later date. diff --git a/files/en-us/web/privacy/partitioned_cookies/index.md b/files/en-us/web/privacy/partitioned_cookies/index.md index 64e7b14e5f89eeb..e278d8590b0c8e8 100644 --- a/files/en-us/web/privacy/partitioned_cookies/index.md +++ b/files/en-us/web/privacy/partitioned_cookies/index.md @@ -34,7 +34,7 @@ Browsers with CHIPs support provide a new attribute for the {{httpheader("Set-Co Set-Cookie: __Host-example=34d8g; SameSite=None; Secure; Path=/; Partitioned; ``` -> **Note:** Partitioned cookies must be set with `Secure` and `Path=/`. In addition, it is recommended to use the `__Host` prefix when setting partitioned cookies to make them bound to the hostname and not the registrable domain. +> **Note:** Partitioned cookies must be set with `Secure`. In addition, it is recommended to use the `__Host` prefix when setting partitioned cookies to make them bound to the hostname and not the registrable domain. With `Partitioned` set, the cookie is stored using two keys, the host key and a new **partition key**. The partition key is based on the scheme and {{Glossary("eTLD", "eTLD+1")}} of the top-level URL the browser was visiting when the request was made to the URL endpoint that set the cookie. @@ -54,8 +54,6 @@ Blocking all third-party cookies would currently be problematic, for example in 2. The storage key for the cookie would be `{("https://shoppy.example"), ("3rd-party.example/chat")}`. 3. The user visits various subdomains in the quest to solve their problem that also embed `https://3rd-party.example/chat`, including `https://support.shoppy.example` and `https://checkout.shoppy.example`. The new embedded instances are able to access the cookie because the partition key still matches. -> **Note:** [First-party sets](https://github.com/WICG/first-party-sets) is a proposal that aims to allow site owners to declare a collection of related domains that will act like they are a single top-level site, for the purposes of cookie access mechanisms like CHIPS. - ## Specifications {{Specifications}} diff --git a/files/en-us/web/progressive_web_apps/guides/making_pwas_installable/index.md b/files/en-us/web/progressive_web_apps/guides/making_pwas_installable/index.md index b89f9339ad07c83..04fc9127ec62b3e 100644 --- a/files/en-us/web/progressive_web_apps/guides/making_pwas_installable/index.md +++ b/files/en-us/web/progressive_web_apps/guides/making_pwas_installable/index.md @@ -108,7 +108,7 @@ Support for PWA installation promotion from the web varies by browser and by pla On desktop: -- Firefox and Safari do not support installing PWAs on any desktop operating systems. See [Installing sites as apps](#sites-as-apps), below. +- Firefox and Safari do not support installing PWAs on any desktop operating systems. See [Installing sites as apps](#installing_sites_as_apps), below. - Chrome and Edge support installing PWAs on Linux, Windows, macOS, and Chromebooks. On mobile: diff --git a/files/en-us/web/progressive_web_apps/guides/offline_and_background_operation/push-messaging-1.svg b/files/en-us/web/progressive_web_apps/guides/offline_and_background_operation/push-messaging-1.svg index 34cf1e857fd5eca..084cea95d6cd0e6 100644 --- a/files/en-us/web/progressive_web_apps/guides/offline_and_background_operation/push-messaging-1.svg +++ b/files/en-us/web/progressive_web_apps/guides/offline_and_background_operation/push-messaging-1.svg @@ -1 +1 @@ -
App server
App server
Browser
Browser
Main app
Main app
1. Provision server
with signing keys
1. Provision server...
2. PushManager.subscribe()
2. PushManager.subscribe()
3. Send to app server:
- push service endpoint
- push service public encryption key
3. Send to app server:...
Device
Device
\ No newline at end of file +
App server
App server
Browser
Browser
Main app
Main app
1. Provision server
with signing keys
1. Provision server...
2. PushManager.subscribe()
2. PushManager.subscribe()
3. Send to app server:
- push service endpoint
- push service public encryption key
3. Send to app server:...
Device
Device
\ No newline at end of file diff --git a/files/en-us/web/progressive_web_apps/guides/offline_and_background_operation/push-messaging-2.svg b/files/en-us/web/progressive_web_apps/guides/offline_and_background_operation/push-messaging-2.svg index 80b5fd1f2f8a272..5c115aa220afe55 100644 --- a/files/en-us/web/progressive_web_apps/guides/offline_and_background_operation/push-messaging-2.svg +++ b/files/en-us/web/progressive_web_apps/guides/offline_and_background_operation/push-messaging-2.svg @@ -1 +1 @@ -
App server
App server
Push service
Push service
Browser
Browser
Service worker
Service worker
2. Send push message
2. Send push message
4. Deliver encrypted
push message
4. Deliver encrypted...
3. Verify
push message
signature
3. Verif...
Device
Device
5. Decrypt
push message
5. Decrypt...
6. Fire push event
containing message
6. Fire push event...
7. Handle
message
7. Handle...
8. Display
notification
8. Display...
1. Encrypt and sign
push message
1. Encrypt and sign...
9. Handle
notification
response
9. Handle...
\ No newline at end of file +
App server
App server
Push service
Push service
Browser
Browser
Service worker
Service worker
2. Send push message
2. Send push message
4. Deliver encrypted
push message
4. Deliver encrypted...
3. Verify
push message
signature
3. Verif...
Device
Device
5. Decrypt
push message
5. Decrypt...
6. Fire push event
containing message
6. Fire push event...
7. Handle
message
7. Handle...
8. Display
notification
8. Display...
1. Encrypt and sign
push message
1. Encrypt and sign...
9. Handle
notification
response
9. Handle...
\ No newline at end of file diff --git a/files/en-us/web/progressive_web_apps/guides/what_is_a_progressive_web_app/pwa-environment.svg b/files/en-us/web/progressive_web_apps/guides/what_is_a_progressive_web_app/pwa-environment.svg index 3a81d6b0482c248..3376a610f93532a 100644 --- a/files/en-us/web/progressive_web_apps/guides/what_is_a_progressive_web_app/pwa-environment.svg +++ b/files/en-us/web/progressive_web_apps/guides/what_is_a_progressive_web_app/pwa-environment.svg @@ -1 +1 @@ -
Platform-specific app
Platform-specific...
Progressive web app
Progressive web app
Browser engine
Browser engine
Operating system
Operating system
Traditional website
Traditional websi...
Browser UI
Browser UI
Device
Device
\ No newline at end of file +
Platform-specific app
Platform-specific...
Progressive web app
Progressive web app
Browser engine
Browser engine
Operating system
Operating system
Traditional website
Traditional websi...
Browser UI
Browser UI
Device
Device
\ No newline at end of file diff --git a/files/en-us/web/progressive_web_apps/how_to/define_app_icons/index.md b/files/en-us/web/progressive_web_apps/how_to/define_app_icons/index.md index c4469ff0ccf9799..6cfaabac59b1d9d 100644 --- a/files/en-us/web/progressive_web_apps/how_to/define_app_icons/index.md +++ b/files/en-us/web/progressive_web_apps/how_to/define_app_icons/index.md @@ -30,7 +30,7 @@ Designing your icon as an SVG file is a good idea, as this will allow it to be s Use the [`icons`](/en-US/docs/Web/Manifest/icons) web app manifest member to define a set of icons for your PWA. -As described in [Create the necessary icon sizes](#create-the-necessary-icon-sizes), you should create multiple versions of your icon to ensure it appears correctly in all the places where it's used. This is why the `icons` member is an array of objects, each of which represents an icon, with its own size, type, and purpose. Each icon object has the following properties: +As described in [Create the necessary icon sizes](#create_the_necessary_icon_sizes), you should create multiple versions of your icon to ensure it appears correctly in all the places where it's used. This is why the `icons` member is an array of objects, each of which represents an icon, with its own size, type, and purpose. Each icon object has the following properties: - `src` - : The URL of the icon image file. @@ -117,7 +117,7 @@ The following web app manifest example uses a WebP image for the small icon, an } ``` -Learn more about how to reference the various icon sizes in [Reference your icons in the web app manifest](#reference-your-icons-in-the-web-app-manifest). +Learn more about how to reference the various icon sizes in [Reference your icons in the web app manifest](#reference_your_icons_in_the_web_app_manifest). ## Support masking diff --git a/files/en-us/web/progressive_web_apps/how_to/display_badge_on_app_icon/index.md b/files/en-us/web/progressive_web_apps/how_to/display_badge_on_app_icon/index.md index 855a6c4f2a67465..f23c7721a96be66 100644 --- a/files/en-us/web/progressive_web_apps/how_to/display_badge_on_app_icon/index.md +++ b/files/en-us/web/progressive_web_apps/how_to/display_badge_on_app_icon/index.md @@ -38,7 +38,7 @@ Before learning how to use badges, consider these best practices to ensure your ### Check for support -To ensure the Badging API is [supported](#support-for-badges) in the user's browser and operating system, to prevent throwing a JavaScript error, check for support before using the API: +To ensure the Badging API is [supported](#support_for_badges) in the user's browser and operating system, to prevent throwing a JavaScript error, check for support before using the API: ```js if (navigator.setAppBadge) { @@ -70,7 +70,7 @@ Like notifications, badges can be a very effective way to re-engage users with y Make sure to update your application badge in real-time. This means updating the badge count to reflect how many new items are actually left for the user to consume, and clearing the app badge when there are no new items. -For example, if an email client app receives new messages in the background, it should update its badge to display the right number of unread messages in the inbox, potentially filtering out messages from other folders such as a spam folder. It's possible to [update badges in the background](#updating-the-badge-in-the-background) by using the `navigator.setAppBadge()` method from a service worker. +For example, if an email client app receives new messages in the background, it should update its badge to display the right number of unread messages in the inbox, potentially filtering out messages from other folders such as a spam folder. It's possible to [update badges in the background](#updating_the_badge_in_the_background) by using the `navigator.setAppBadge()` method from a service worker. Once the user launches the app and starts reading messages, the email client app should update its badge accordingly by calling `navigator.setAppBadge()` with the new unread messages count, or by calling `navigator.clearAppBadge()` when there are no unread messages. diff --git a/files/en-us/web/progressive_web_apps/how_to/share_data_between_apps/index.md b/files/en-us/web/progressive_web_apps/how_to/share_data_between_apps/index.md index e2f1d6be329263f..64964d5f1d874dc 100644 --- a/files/en-us/web/progressive_web_apps/how_to/share_data_between_apps/index.md +++ b/files/en-us/web/progressive_web_apps/how_to/share_data_between_apps/index.md @@ -73,7 +73,7 @@ async function shareData(data) { ### Sharing text data -The following example demonstrates how to share a link and some text when a button in the app is clicked. The `canBrowserShareData` function used in the example is described in [Checking for support](#checking-for-support) and not repeated here. +The following example demonstrates how to share a link and some text when a button in the app is clicked. The `canBrowserShareData` function used in the example is described in [Checking for support](#checking_for_support) and not repeated here. ```js // Retrieve the button from the DOM. The button is hidden for now. diff --git a/files/en-us/web/progressive_web_apps/tutorials/cycletracker/html_and_css/index.md b/files/en-us/web/progressive_web_apps/tutorials/cycletracker/html_and_css/index.md index 8b54c4506aac93c..1a9e0ba40c41fe6 100644 --- a/files/en-us/web/progressive_web_apps/tutorials/cycletracker/html_and_css/index.md +++ b/files/en-us/web/progressive_web_apps/tutorials/cycletracker/html_and_css/index.md @@ -61,7 +61,7 @@ Copy this HTML and save it in a file called `index.html`. ## HTML content -Even if the HTML in `index.html` is familiar to you, we recommend reading through this section before adding some [temporary hard-coded data](#temporary-hard-coded-results-text), adding CSS to a [`style.css`](#css-content) external stylesheet, and creating `app.js`, the [application's JavaScript](/en-US/docs/Web/Progressive_web_apps/Tutorials/CycleTracker/JavaScript_functionality) that makes this web page function. +Even if the HTML in `index.html` is familiar to you, we recommend reading through this section before adding some [temporary hard-coded data](#temporary-hard-coded-results-text), adding CSS to a [`style.css`](#css_content) external stylesheet, and creating `app.js`, the [application's JavaScript](/en-US/docs/Web/Progressive_web_apps/Tutorials/CycleTracker/JavaScript_functionality) that makes this web page function. The HTML's first line is a {{glossary("doctype")}} preamble, which ensures the content behaves correctly. @@ -234,7 +234,7 @@ li:nth-of-type(even) { } ``` -If every line is familiar to you, you can copy the above CSS, or write your own CSS, and save the file as [`style.css`](https://github.com/mdn/pwa-examples/tree/main/cycletracker/html_and_css/style.css), then [finish up the static HTML and CSS](#finishing-the-static-html-and-css-for-our-pwa). If anything in the above CSS is new to you, keep reading for an explanation. +If every line is familiar to you, you can copy the above CSS, or write your own CSS, and save the file as [`style.css`](https://github.com/mdn/pwa-examples/tree/main/cycletracker/html_and_css/style.css), then [finish up the static HTML and CSS](#finishing_the_static_html_and_css_for_our_pwa). If anything in the above CSS is new to you, keep reading for an explanation. ![Light green web page with a large header, a form with a legend, two date pickers and a button. The bottom shows fake data for two menstrual cycles and a header.](html.jpg) diff --git a/files/en-us/web/progressive_web_apps/tutorials/cycletracker/manifest_file/index.md b/files/en-us/web/progressive_web_apps/tutorials/cycletracker/manifest_file/index.md index cfb964d960d978c..2c6f500da40c89a 100644 --- a/files/en-us/web/progressive_web_apps/tutorials/cycletracker/manifest_file/index.md +++ b/files/en-us/web/progressive_web_apps/tutorials/cycletracker/manifest_file/index.md @@ -43,7 +43,7 @@ To identify your PWA, the JSON must include a `name` or `short_name` member, or When both the `name` and `short_name` are present, the `name` is used in most instances, with the `short_name` used when there is a limited space to display the application name. - [`description`](/en-US/docs/Web/Manifest/description) - - : Explanation of what the application does. It provides an [accessible description](/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-description) of the application's purpose and function. + - : Explanation of what the application does. It provides an {{glossary("accessible description")}} of the application's purpose and function. ### Task @@ -132,7 +132,7 @@ Within the manifest JSON object, the `icons` member specifies an array of one or } ``` -All icons should have the same look and feel to ensure users recognize your PWA, but the larger the icon, the greater the detail it can contain. While all icon files are squares, some operating systems render different shapes, cutting sections off, or "masking" the icon, to meet the UI, or shrinking and centering the icon with a background if the icon is not maskable. The [safe zone](/en-US/docs/Web/Progressive_web_apps/How_to/Define_app_icons#support-masking), the area that will render okay if the icon is masked as a circle, is the inner 80% of the image file. Icons are labeled as safe to be masked by the `purpose` member which, when set to `maskable`, defines the [icon as adaptive](https://web.dev/articles/maskable-icon). +All icons should have the same look and feel to ensure users recognize your PWA, but the larger the icon, the greater the detail it can contain. While all icon files are squares, some operating systems render different shapes, cutting sections off, or "masking" the icon, to meet the UI, or shrinking and centering the icon with a background if the icon is not maskable. The [safe zone](/en-US/docs/Web/Progressive_web_apps/How_to/Define_app_icons#support_masking), the area that will render okay if the icon is masked as a circle, is the inner 80% of the image file. Icons are labeled as safe to be masked by the `purpose` member which, when set to `maskable`, defines the [icon as adaptive](https://web.dev/articles/maskable-icon). In Safari, and therefor for iOS and iPadOS, if you include the [non-standard `apple-touch-icon`](/en-US/docs/Learn/HTML/Introduction_to_HTML/The_head_metadata_in_HTML#adding_custom_icons_to_your_site) in the {{HTMLElement("head")}} of the HTML document via {{HTMLElement("link")}}, they will take precedence over manifest-declared icons. diff --git a/files/en-us/web/progressive_web_apps/tutorials/cycletracker/service_workers/index.md b/files/en-us/web/progressive_web_apps/tutorials/cycletracker/service_workers/index.md index 9ac446ff0d9197d..8c6a2e3ac8adec8 100644 --- a/files/en-us/web/progressive_web_apps/tutorials/cycletracker/service_workers/index.md +++ b/files/en-us/web/progressive_web_apps/tutorials/cycletracker/service_workers/index.md @@ -197,7 +197,7 @@ We can take advantage of the [`fetch`](/en-US/docs/Web/API/ServiceWorkerGlobalSc As our PWA consists of a single page, for page navigation requests, we go back to the `index.html` home page. There are no other pages and we don't ever want to go to the server. If the Fetch API's [`Request`](/en-US/docs/Web/API/Request) readonly [`mode`](/en-US/docs/Web/API/Request/mode) property is `navigate`, meaning it's looking for a web page, we use the FetchEvent's [`respondWith()`](/en-US/docs/Web/API/FetchEvent/respondWith) method to prevent the browser's default fetch handling, providing our own response promise employing the [`caches.match()`](/en-US/docs/Web/API/CacheStorage/match) method. -For all other request modes, we open the caches as done in the [install event response](#saving-the-cache-on-pwa-installation), instead passing the event request to the same `match()` method. It checks if the request is a key for a stored {{domxref("Response")}}. If yes, it returns the cached response. If not, we return a [404 status](/en-US/docs/Web/HTTP/Status/404) as a response. +For all other request modes, we open the caches as done in the [install event response](#saving_the_cache_on_pwa_installation), instead passing the event request to the same `match()` method. It checks if the request is a key for a stored {{domxref("Response")}}. If yes, it returns the cached response. If not, we return a [404 status](/en-US/docs/Web/HTTP/Status/404) as a response. Using the [`Response()`](/en-US/docs/Web/API/Response/Response) constructor to pass a `null` body and a `status: 404` as options, doesn't mean there is an error in our PWA. Rather, everything we need should already be in the cache, and if it isn't, we're not going to the server to resolve this non-issue. @@ -367,7 +367,7 @@ Because of the way we have set up the service worker, once it is registered, eve ### By updating the version number and doing a hard reset -To get a new cache, you can change the [version number](#version-number) and then do a hard browser refresh. The way you do a hard refresh depends on the browser and operating system: +To get a new cache, you can change the [version number](#version_number) and then do a hard browser refresh. The way you do a hard refresh depends on the browser and operating system: - On Windows: Ctrl+F5, Shift+F5, or Ctrl+Shift+R. - On MacOS: Shift+Command+R. @@ -388,7 +388,7 @@ In some developer tools, you can manually unregister a service worker, or you ca The service worker window within the DevTools' application panel, provides a link to access to pop up window containing a list of all the registered service workers for the browser; not just the service worker for the application opened in the current tab. Each service worker list of workers has buttons to stop, start, or unregister that individual service worker. -![Two service workers exist at localhost:8080. The can be be unregistered from the list of service workers](edge_sw_list.jpg) +![Two service workers exist at localhost:8080. The can be unregistered from the list of service workers](edge_sw_list.jpg) In other words, as you are working on your PWA, you don't have to update the version number for every app view. But remember, when you are done with all your changes, update the service worker VERSION value before distributing the updated version of your PWA. If you forget, no one who has already installed your app or even visited your online PWA without installing it will ever get to see your changes! diff --git a/files/en-us/web/progressive_web_apps/tutorials/js13kgames/app_structure/index.md b/files/en-us/web/progressive_web_apps/tutorials/js13kgames/app_structure/index.md index 042c46d6e7dbb68..d8285af632fbfc7 100644 --- a/files/en-us/web/progressive_web_apps/tutorials/js13kgames/app_structure/index.md +++ b/files/en-us/web/progressive_web_apps/tutorials/js13kgames/app_structure/index.md @@ -91,7 +91,6 @@ const template = `

#POS. NAME