| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Web Share</title> | |
| <script> | |
| function initiate_share() { | |
| if (navigator.share === undefined) { | |
| window.document.title = 'Fail: navigator.share === undefined'; | |
| return; | |
| } | |
| const fileBits = ['contents']; | |
| const fileName = 'sample.dex'; | |
| // Arbitrary MIME type present in PERMITTED_MIME_TYPES. | |
| // If successful, the share Intent has the file's MIME | |
| // type (or text/plain if no file is being shared). | |
| const options = {type: 'text/plain'}; | |
| const data = {files: [new File(fileBits, fileName, options)]}; | |
| navigator.share(data).then(() => { | |
| window.document.title = 'Success'; | |
| }).catch(e => { | |
| window.document.title = 'Fail: ' + e; | |
| }); | |
| } | |
| window.addEventListener('load', () => { | |
| window.addEventListener('click', initiate_share); | |
| }); | |
| </script> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |