开发者

use javascript variable as url for addthis:url

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 t开发者_高级运维ype="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 ?


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>


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜