Is it possible to trigger share menu on smartphones (via HTML/JS)?

后端 未结 6 1176
半阙折子戏
半阙折子戏 2020-12-04 21:13

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

6条回答
  •  生来不讨喜
    2020-12-04 21:40

    It is possible and I wrote a function to have pretty content to share and observe the asynchronous side effects:

    const shareContact = async (title, content) => {
      const text = `${title}
    
    ${content}`;
    
      try {
        await navigator.share({
          text,
        });
      } catch (e) {
        console.log(e);
      }
    };
    

提交回复
热议问题