How to dynamically create “Share This buttons” with a custom URLs with a javascript function?

血红的双手。 提交于 2019-11-29 09:51:22
Cubed Eye

I've been using the

stButtons.locateElements();

function to generate any new buttons after loading content via AJAX, I imagine it will work for this too.

This question might be of some assistance also:

Sharethis button does not work on pages loaded via ajax

Better Solution:

Make your <div> and make sure all the <span>s have IDs, otherwise you can give them classes but you will need to iterate through them all.

function shareChannel(theurl, thetitle)
    {
    document.getElementById('spanID1').setAttribute('st_url', theurl);
    document.getElementById('spanID1').setAttribute('st_title', thetitle);

    stButtons.locateElements();

    //finally display the popup after the buttons are made and setup.
    displaypopup();
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!