samedi 21 février 2015

javascript widget - async - Two widgets gets mixed


I created a widget where the parameters id and hashgurus_id alone changes. These are the parameters that define a country. The other code in the widget remain the same.


for egypt it is:



<script id="egypt" async type="text/javascript">
var hashgurus_woeid = 23424802;
var hashgurus_id = "egypt";
</script>

<script async src="http://ift.tt/1zrpN3n"></script>


and for turkey the widget is:



<script id="turkey" async type="text/javascript">
var hashgurus_woeid = 23424969;
var hashgurus_id = "turkey";
</script>

<script async src="http://ift.tt/1zrpN3n"></script>


The livetrend script code is-



var div = document.createElement('div');
div.id = "FJ_TF_Cont";
div.style.position = 'relative';
div.style.padding = '10px';
div.style.margin = '10px';
div.style.borderWidth = 0;
div.style.width = '200px';
div.innerHTML = '<iframe width="210" height="350" src="http://ift.tt/1CPZ4hO' + hashgurus_woeid +'" '
+ 'name="FJIframe" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" style="width: 210px; border-width: 0px; z-index: 1;">'
+ '</iframe>';

var myScript = document.getElementById(hashgurus_id);
alert(hashgurus_id);
myScript.parentElement.insertBefore(div, myScript.nextSibling);


I used both of this widget in one of my blogspot:


http://ift.tt/1MCmQGe


The problem is because I used two widgets for the posts I get only for one. The other doesnot work


Now that if you see this widget only in one post it works perfectly. the URL being for egypt and http://ift.tt/1zrpKV4


URL for turkey being: http://ift.tt/1MCmQGh


Please click on the links as I have put a demo to show how this works perfectly independently but doesnot work when its put together.





Aucun commentaire:

Enregistrer un commentaire