System Share
share() method for opening native share dialog
Ready to run
await navigator.share({
title: 'Заголовок',
text: 'Текст для обмена',
url: 'https://example.com'
});
Parameters:
titleOptional - title to sharetextOptional - text to shareurlOptional - URL to sharefilesOptional - array of files to share (File[])
Method returns a Promise that resolves when sharing is successful or rejects if the user cancels the operation.
Note: API is only available in secure contexts (HTTPS) and requires user gesture.
canShare() method for checking if sharing is possible
Ready to run
if (navigator.canShare) {
const canShare = navigator.canShare({
title: 'Заголовок',
text: 'Текст',
url: 'https://example.com'
});
console.log('Can share:', canShare);
}
Method checks if the specified data can be shared. Returns true or false.
Parameters are similar to share() method.