我使用以下函数来设置addthis:title属性:
function setTheTitle(){
if(jQuery(".title").length > 0){
shareTitle = jQuery(".title").text();
jQuery("#shareButton").attr("addthis:title", shareTitle);
} else {
setTimeout(function(){
setTheTitle();
},100)
}
}
问题是, shareTitle 变量是通过JSON对象生成的,需要几秒钟才能加载。
在此之前,addthis javascript加载,并看到空url attr ,设置页面默认标题。
<script src="http://www.../external_share_script.js" type="text/javascript">share script</script>
<a href="#" id="shareButton" addthis:title="" addthis:url="">the link</a>
如何在我获得价值之前延迟addthis javascript的加载?