如何使用addthis社交插件分享url +参数?
我读过addthis api,但我找不到乳清来添加我的参数
http://support.addthis.com/customer/portal/articles/381263-addthis-client-api
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>hello world</title>
</head>
<body>
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_compact"></a>
<a class="addthis_counter addthis_bubble_style"></a>
</div>
<script type="text/javascript">
var addthis_config = {
// I want to share link as this url + my_defined_paramater, how to set?
url: location.href+'refer_id=1900' //not correct
};
</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#username=addthis"></script>
<!-- AddThis Button END -->
</body>
</html>
答案 0 :(得分:2)
看起来你的网址可能需要一个&符号。其他所有内容从API文档显示的内容看起来都很好。
var addthis_config = {
// I want to share link as this url + my_defined_paramater, how to set?
url: location.href+'&refer_id=1900'
//^^^
};
我在支持部分找到了一些项目。希望这会有所帮助。
基本上,它表示您可以添加名为addthis:url
的属性来设置自定义网址。由于您需要当前页面,因此您必须使用JavaScript的setAttribute()
方法更新它。
<div class="addthis_toolbox addthis_default_style" id="addthis_container">
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_compact"></a>
<a class="addthis_counter addthis_bubble_style"></a>
</div>
<script type="text/javascript">
var addThisCont = document.getElementById("addthis_container");
var curUrl = location.protocol + "//" + location.href;
var withGetVariable = curUrl + "?refer_id=1900";
addThisCont.setAttribute("addthis:url", withGetVariable);
</script>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#username=addthis"></script>
答案 1 :(得分:0)
您应该使用以下代码:
addthis_share = {
url_transforms : {
add: {
oReferrer: LoggedOfficeGuid
}
}
}