Skip to content

Commit

Permalink
Docs: Extend examples for inline <script> usage
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM committed Dec 6, 2021
1 parent e6aeae2 commit 287c69d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ window.addEventListener('load', function () {
```

This will load the plugin from CDN and initialize the plugin with default settings.
[👀 See example][examples].

[👀 See demo page with example][examples].

## Loading the plugin

Expand Down Expand Up @@ -182,9 +183,14 @@ set `type` to `type="text/plain"` and add `data-cookiecategory` attribute with r
```html
<script src="personalization.js" type="text/plain" data-cookiecategory="personalization" defer></script>
<script type="text/plain" data-cookiecategory="functionality">
console.log('functionality consent given');
</script>
```
See [full documentation](https://github.com/orestbida/cookieconsent#manage-third-party-scripts) for this feature.
[👀 This feature is shown in examples][examples].
See also [full documentation](https://github.com/orestbida/cookieconsent#manage-third-party-scripts) for this feature.
This feature is enabled by default. If you'd like to disable it, you can do so by overriding `page_scripts` value in
`config` option:
Expand Down
8 changes: 8 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ <h2 class="mt-4 mt-md-5 mb-3">Content set by external script when <code>personal
(empty)
</p>

<h2 class="mt-4 mt-md-5 mb-3">Content set using inline <code>&lt;script&gt;</code></h2>
<script type="text/plain" data-cookiecategory="functionality">
document.getElementById('functionality-content').innerText = 'Consent for functionality category was given';
</script>
<p id="functionality-content">
(empty)
</p>

<h2 class="mt-4 mt-md-5 mb-3">Allowed consent categories</h2>
<ul class="list-group">
<li class="list-group-item" id="consent-necessary">necessary</li>
Expand Down

0 comments on commit 287c69d

Please sign in to comment.