javascript - how to share url + parameter using addthis social plugin? -
how share url + parameter using addthis social plugin?
had read addthis api, can not find whey add parameters.
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 = { // want share link url + my_defined_paramater, how 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>
looks may need ampersand in url. else looks fine api docs show.
var addthis_config = { // want share link url + my_defined_paramater, how set? url: location.href+'&refer_id=1900' //^^^ };
i found items in support section. help.
basically, says can add attribute called addthis:url
set custom url. since need current page, you'll have update javascript's setattribute()
method.
<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>
Comments
Post a Comment