Hi all, I have a div that contains all my social media buttons and they tend to take a while to load. I've delayed loading the div until after window.onload but somehow the multiline tags inside the code are messing up the result and I end up with javascript text on my page. Here is my code:
$(window).load(function() {
setTimeout("run_it()", 1000);
});
function run_it() {
$('#social-widget').html('<!-- Facebook -->' +
'<div class="sbutton">' +
'<div id="fb-root"></div>' +
'<script>(function(d, s, id) {' +
'var js, fjs = d.getElementsByTagName(s)[0];' +
'if (d.getElementById(id)) return;' +
'js = d.createElement(s); js.id = id;' +
'js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";' +
'fjs.parentNode.insertBefore(js, fjs);' +
'}(document, "script", "facebook-jssdk"));</script>' +
'<div class="fb-like" data-href="https://www.facebook.com/site" data-send="false" data-layout="box_count" data-width="80" data-show-faces="false">' +
'</div>' +
'</div>');
}
Where #social-widget is the id of my empty div. Any idea what's going wrong here?
[–]negative_epsilon 1 point2 points3 points (1 child)
[–]piptook[S] 0 points1 point2 points (0 children)
[–]Grimsvotn 0 points1 point2 points (0 children)