简体   繁体   中英

how to make repost button on website for mobile phones, which uses inside repost function

I need to realize current page link share button on website, i tried to do it using webshare api, but on all devices i got alert that browser version is out of date and i need to update it. Can you suggest any other ways?

 var shareButton = document.getElementById('share-button'); shareButton.addEventListener('click', function () { if (navigator.share) { console.log("Your browser support") navigator.share({ title: "title", text: "text", url: window.location.href, }).then(function () { console.log("Success") }).catch(function () { console.log("Error") }) } else { alert("Your browser version is out of date") } })'''
 <div class="share-button-plugin mt-30"> <button id="share-button"><i class="fa fa-share-alt"></i>Share</button> </div>

On Firefox website ( https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share ) is written that you should use navigator.canShare()

Also, there is a note:

Secure context. This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

I would not use this feature in general, due to poor browser compatibility:

https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share#Browser_compatibility

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM