我正在查看Facebook的分享按钮的最新更新. 似乎不再可能在网站中包含分享按钮而不包括Facebook javascript SDK,或者在某个地方提供Facebook应用程序以提供应用程序ID?
分享按钮示例1使用Facebook SDK
FB.ui({
method: 'share',
href: 'https://developers.facebook.com/docs/',
}, function(response){});
Run Code Online (Sandbox Code Playgroud)
共享按钮示例2使用自定义应用程序ID
https://www.facebook.com/dialog/share?
app_id=145634995501895
&display=popup
&href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2F
&redirect_uri=https%3A%2F%2Fdevelopers.facebook.com%2Ftools%2Fexplorer
Run Code Online (Sandbox Code Playgroud)
问题:如何使用一行代码为Facebook构建简单明了的共享按钮,不需要库和应用程序ID?
Rez*_*eza 67
你可以使用facebook sharer链接和一个简单的弹出窗口来完成这项工作
$("#facebookShareLink").on("click",function(){
var fbpopup = window.open("https://www.facebook.com/sharer/sharer.php?u=http://stackoverflow.com", "pop", "width=600, height=400, scrollbars=no");
return false;
});
Run Code Online (Sandbox Code Playgroud)
Car*_*ela 10
有可能的.不需要FB应用程序来简单地共享URL.创建一个简单的弹出窗口并使用Facebook共享对话框.
https://developers.facebook.com/docs/sharing/reference/share-dialog目前, 它仍然包含在他们的API中.
window.open("https://www.facebook.com/sharer/sharer.php?u=http://www.gmanetwork.com/news/", "pop", "width=600, height=400, scrollbars=no");
Run Code Online (Sandbox Code Playgroud)
创建每次都会弹出窗口的功能.
function openURLInPopup(url, width, height, name) {
if (typeof(width) == "undefined") {
width = 800;
height = 600;
}
if (typeof(height) == "undefined") {
height = 600;
}
popup(url, name || 'window' + Math.floor(Math.random() * 10000 + 1), width, height, 'menubar=0,location=0,toolbar=0,status=0,scrollbars=1');
}
Run Code Online (Sandbox Code Playgroud)
那你的链接应该是这样的For Twitter:
<a class="btn_twitter" onclick="openURLInPopup('http://twitter.com/home?status=http://www.domain.ro/url.html',600, 400); return false;" href="#" target="_blank">Twitter</a>
Run Code Online (Sandbox Code Playgroud)
对于Facebook:
<a class="btn_fb" onclick="openURLInPopup('http://www.facebook.com/sharer.php?u=http://www.domain.ro/url.html',600, 400); return false;" href="#" target="_blank">Facebook</a>
Run Code Online (Sandbox Code Playgroud)
对于谷歌
<a class="btn_gplus" onclick="openURLInPopup('https://plus.google.com/share?url=http://www.domain.ro/url.html',600, 400); return false;" href="#">gplus</a>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29691 次 |
| 最近记录: |