Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
195
rated 0 times [  198] [ 3]  / answers: 1 / hits: 42215  / 11 Years ago, wed, april 10, 2013, 12:00:00

Is there an existing possibility to trigger the share functionality in local browsers on smartphones via HTML or JavaScript?



Of course there are many services which provide a share button. But when I e.g. want to share a website on facebook, I need to be logged in to facebook in the browser I am currently using.



Almost all browsers got an own share functionality build in, which triggers a system menu to choose which app you want to use to share:



System



This question is about: How to trigger this menu?



I know it is possible to trigger a phone call with a specified prefix in href attribute of links, like tel: or callto:. Maybe such a shortcut for this share menu is also existing? Or some javascript code? Or a totally different way how to do it?



Thanks in advance.


More From » android

 Answers
19

I added this as all answers seems outdated by 2018-07-16.




It is possible, but only in a few browsers (MDN Reference), achieved througth the one method API in navigator:



navigator
.share({
title: document.title,
text: 'Hello World',
url: window.location.href
})
.then(() => console.log('Successful share! 🎉'))
.catch(err => console.error(err));


Google's reference: https://developers.google.com/web/updates/2016/10/navigator-share



Also, there was a thing called Web Intends which is a dead project, you should go with navigator.share instead.


[#79002] Tuesday, April 9, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ariel

Total Points: 523
Total Questions: 111
Total Answers: 100

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
;