0

I need to pass a url to addthis, and this is the default code

<div class="addthis_toolbox addthis_default_style" addthis:url="http://www.google.com" >

I need to pass the url to addthis with a javascript variable, I need it something like

<script type="text/javascript">
    var currentUrl = 'http://www.google.com'; 
</script>
<div class="addthis_toolbox addthis_default_style" addthis:url=currentUrl >

Do you know the syntax to add this javascript variable ?

2 Answers 2

2

First, add id to the div:

<div id="MyAddThisToolbox" class="addthis_toolbox .....>

Then have this code after the <div> tag in the body of your page:

<script type="text/javascript">
   document.getElementById("MyAddThisToolbox").setAttribute("addthis:url", currentUrl); 
</script>
Sign up to request clarification or add additional context in comments.

Comments

0

I don't know what 'addthis' is but you can try following:

<div ... addthis:url="javascript:currentUrl">...</div>.

Can you explain what 'addThis:url' is and where have you got it?

1 Comment

hi, This is where it is from addthis.com/help/url-and-title And also found how to change the url, it can be done with this script <script type="text/javascript"> var shareUrl = "msn.com"; addthis.update('share', 'url', shareUrl); </script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.