Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
24 lines (24 loc) · 1.76 KB
/
Copy pathindex.html
File metadata and controls
24 lines (24 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Web Share | CoCreateJS</title>
<meta name="description" content="Declarative access to the browser Web Share API.">
</head>
<body>
<main>
<h1>Web Share</h1>
<p>Open the device's native share sheet with a URL and text. The user chooses an available destination. The share sheet must be opened directly from a user action, and support depends on the browser and device.</p>
<h2>Usage</h2>
<pre><code><button share share-title="A page" share-text="Take a look" share-url="https://example.com">Share</button></code></pre>
<p>On an anchor, the share trigger shares its <code>href</code> by default and prevents navigation. Set <code>share-url</code> to override it. A button defaults to the current page URL.</p>
<p>To share selected files, keep the file picker separate and point the share button at it with <code>share-files-query</code>:</p>
<pre><code><input id="files-to-share" type="file" accept="image/*" multiple>
<button share share-files-query="$document #files-to-share">Share selected files</button></code></pre>
<p>Or use <code>actions="share"</code> to run sharing in an action chain. Add <code>share.canShare</code> before <code>share</code> to pre-check the payload; it continues on <code>true</code> and aborts on <code>false</code>. The actual share still requires a user action.</p>
<pre><code><button actions="share.canShare, share" share-title="A page" share-url="https://example.com">Share if supported</button></code></pre>
<p><a href="/docs/web-share/demo">Open the demo</a></p>
</main>
</body>
</html>