Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Loading widgets on click


Fotiman - 1:58 pm on Mar 12, 2013 (gmt 0)


It's the call to loadScript that's loading it, so you would want to move that to your onclick handler. Note, though, that you'll want to set some global flag when it has been loaded to prevent loading it multiple times. For example:

var triggerElement = document.getElementById('trigger'),
addThisLoaded = false;
trigger.onclick = function () {
if (!addThisLoaded) {
loadScript("http://s7.addthis.com/js/250/addthis_widget.js#pub=example",
function() {
addThisLoaded = true;
});
}
};

Then in your markup, give whatever element is supposed to be the trigger for loading it an id of 'trigger' (or change this code example to get the element however you like). :)


Thread source:: http://www.webmasterworld.com/javascript/4553579.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com