Load Load JavaScript with extra tags for example data-shr-siteid or data-sumo-site-id
You can use below code.
<script>
var loadScript = function(location, callback){
var fileRef = document.createElement('script');
fileRef.setAttribute('type','text/javascript');
if (callback) {
if (fileRef.readyState) { // IE
fileRef.onreadystatechange = function() {
if (fileRef.readyState == 'loaded' || fileRef.readyState == 'complete') {
fileRef.onreadystatechange = null;
callback();
}
};
} else { // Non-IE
fileRef.onload = function(){
callback();
};
}
}
fileRef.setAttribute('src', location);
fileRef.setAttribute('data-shr-siteid', '<?php echo $api_key; ?>');
fileRef.async = true;
document.head.appendChild(fileRef);
};
function doss() {
var surl='<?php echo ShareaholicUtilities::asset_url('assets/pub/shareaholic.js') ?>';
loadScript(surl, function() {
// CALLBACK - code that does something with the data returned by loading the script
});
}
setTimeout("doss();",6000);
</script>
<script>
var loadScript = function(location, callback){
var fileRef = document.createElement('script');
fileRef.setAttribute('type','text/javascript');
if (callback) {
if (fileRef.readyState) { // IE
fileRef.onreadystatechange = function() {
if (fileRef.readyState == 'loaded' || fileRef.readyState == 'complete') {
fileRef.onreadystatechange = null;
callback();
}
};
} else { // Non-IE
fileRef.onload = function(){
callback();
};
}
}
fileRef.setAttribute('src', location);
fileRef.setAttribute('data-shr-siteid', '<?php echo $api_key; ?>');
fileRef.async = true;
document.head.appendChild(fileRef);
};
function doss() {
var surl='<?php echo ShareaholicUtilities::asset_url('assets/pub/shareaholic.js') ?>';
loadScript(surl, function() {
// CALLBACK - code that does something with the data returned by loading the script
});
}
setTimeout("doss();",6000);
</script>
0 comments:
Post a Comment