【发布时间】:2013-11-24 13:56:35
【问题描述】:
我们可以使用手机 (android/Iphones) 的原生分享功能来分享来自应用的不同内容。是否也可以在所有智能手机中使用 javascript 通过浏览器调用此共享功能?这样在浏览器中的某些事件上,我们可以加载共享小部件。
谢谢。
【问题讨论】:
标签: javascript android jquery ios
我们可以使用手机 (android/Iphones) 的原生分享功能来分享来自应用的不同内容。是否也可以在所有智能手机中使用 javascript 通过浏览器调用此共享功能?这样在浏览器中的某些事件上,我们可以加载共享小部件。
谢谢。
【问题讨论】:
标签: javascript android jquery ios
是的,现在您可以使用适用于 Android 的 Javascript 共享它。 如果您需要更多详细信息或表示感谢,请点击链接
https://sdtuts.com/javascript-android-native-share-popup-navigator-share-api/
async function AndroidNativeShare(Title,URL,Description){
if(typeof navigator.share==='undefined' || !navigator.share){
alert('Your browser does not support Android Native Share');
} else {
const TitleConst = Title;
const URLConst = URL;
const DescriptionConst = Description;
try{
await navigator.share({title:TitleConst, text:DescriptionConst, url:URLConst});
} catch (error) {
console.log('Error sharing: ' + error);
return;
}
}
}
$(".share_button").click(function(){
AndroidNativeShare('My Page Title', 'https://google.com','This is description');
});
【讨论】:
对于 iOS/Android,只有在应用程序中打开 UIWebView 时才有可能,而不是从原生 Safari/Chrome 独立浏览器中打开。
来自应用内网页视图:How to Call Native Iphone/Android function from Javascript?
【讨论】:
不是 jquery 本身,而是 Chrome for Android 和 Android 的本机浏览器对此提供支持: https://developer.chrome.com/multidevice/android/intents
不幸的是,文档非常有限,因为我试图弄清楚如何通过共享对话框共享链接(让用户可以选择与哪个应用共享链接)。
【讨论】: