I have this code which is driving me mad.
parent.document.write("<script type='application/javascript' scr='http://backlinker.nl/ip.php?callback=getip'><\/script>");
this works and adds to the head section of the html document :
<script type='application/javascript' scr='http://backlinker.nl/ip.php?callback=getip'></script>
But it does not execute. The difference is when i paste it directly into the head of the html document without the parent.document.write it works AND executes :
<script type='application/javascript' scr='http://backlinker.nl/ip.php?callback=getip'></script>
gives output in firebug html source code :
<script src="http://backlinker.nl/ip.php?callback=getip" type="application/javascript">
getip({"ip": "195.241.100.221"});
</script>
when loaded trough the parent.document.write function NO IP output :
<script src="http://backlinker.nl/ip.php?callback=getip" type="application/javascript">
</script>
Anybody knows why the parent.document.write function is working (it puts the code into the head html section) but not loads the ip ?!
Ok guys we have an alternative which is working but still not answers the question which drives me mad, why is mine not working ?!
The workaround =
var scriptElement = document.createElement("script");
scriptElement.src = 'http://backlinker.nl/ip.php?callback=getip';
scriptElement.type = "text/javascript"; //specify type so that the browser won't ignore it
var head = document.getElementsByTagName("head")[0] || document.documentElement;
head.appendChild(scriptElement);