我正在创建自己的共享菜单,我已经有几个社交分享。但是,LinkedIn会出现问题,因为url似乎没有包含在重定向中。这是其他工作份额的相同代码所以我不知道出了什么问题。
JS
var url = window.location.href+'"';
var title = document.title;
var popup = '<div id="popup"><p id="shareHeader">Share On</p>'+
'<p><a href="http://www.facebook.com/sharer.php?u="'+url+'>Facebook</a></p>'+
'<p><a href="https://www.linkedin.com/shareArticle?mini=true&url="'+url+'&title='+title+'>LinkedIn</a></p>'+
'<p><a href="http://twitter.com/share?text=GET%20800%20SAT&url="'+url+'>Twitter</a></p>'+
'<p><a href="https://plus.google.com/share?url={'+url+'}">Google+</a></p>'+
'<p><a href="http://www.stumbleupon.com/submit?url='+url+'>StumbleUpon</a></p>'+
'</div><div id="close">Close</div>';
答案 0 :(得分:0)
问题是您在将网址附加到href
标记之前将其关闭。
<p><a href= >"< https://www.linkedin.com/shareArticle?mini=true&url= >"< '+url+'&title='+title+'>LinkedIn</a></p>
你需要看起来像这样:
var url = window.location.href+'"';
var title = document.title;
var popup = '<div id="popup"><p id="shareHeader">Share On</p>'+
'<p><a href="http://www.facebook.com/sharer.php?u='+url+'">Facebook</a></p>'+
'<p><a href="https://www.linkedin.com/shareArticle?mini=true&url='+url+'&title='+title+'">LinkedIn</a></p>'+
'<p><a href="http://twitter.com/share?text=GET%20800%20SAT&url='+url+'">Twitter</a></p>'+
'<p><a href="https://plus.google.com/share?url={'+url+'}">Google+</a></p>'+
'<p><a href="http://www.stumbleupon.com/submit?url='+url+'">StumbleUpon</a></p>'+
'</div><div id="close">Close</div>';
答案 1 :(得分:0)
您也可以使用此功能从您的网络应用程序共享。
发布到Facebook的脚本
<script>
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=Your app Id";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
Twitter的脚本
<script async src="//platform.twitter.com/widgets.js" charset="utf-8">
</script>
发布到Linkedn的脚本
<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script>
发布到Google Plus的脚本
<script type="text/javascript">
(function () {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/platform.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
HTML
<div id="fb-root"></div>
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Share on social media</h4>
</div>
<div class="modal-body">
@{
var eventId = "WUIkEyQgjnjxsoQa";
}
<div class="fb-share-button" data-href="http://92.33.32.25/@eventId" data-width="100px" data-type="button"></div>
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://92.33.32.25/@eventId" data-type="button" data-text="Share on eventry" data-via="eventry" data-count="vertical">Tweet</a>
<div class="g-plus" data-action="share" data-expandto="right" data-annotation="none" data-height="22" data-width="55" data-href="http://92.33.32.25/WUIkEyQgjnjxsoQa"></div>
<script type="IN/Share" data-url="http://92.33.32.25/@eventId"> </script>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
共享