I am getting in to this error each time i try to load the following javascript page. But if i do a refresh the error goes away. could any one tell me how to avoid such error at first place?Thanks
Can't execute code from a freed script
pointing at bold part:
function WindowLoad(func)
{
var prev=window.onload;
window.onload=function(){ if(prev)prev(); func(); }
}
Can't execute code from a freed script
pointing at bold part:
function WindowLoad(func)
{
var prev=window.onload;
window.onload=function(){ if(prev)prev(); func(); }
}
Code:
<html>
<body>
<script>
<!--
var REFRESH_TIME = 7000;
var requester;
var musicListRequester;
var timerId;
function getElementById(totalvotes)
{
if (document.all)
{
return document.all(totalvotes);
}
else if (document.getElementById)
{
return document.getElementById(totalvotes);
}
}
function WindowLoad(func)
{
var prev=window.onload;
window.onload=function(){ if(prev)prev(); func(); }
}
function WindowUnload(func)
{
var prev = window.onunload;
window.onunload=function() { if(prev)prev(); func(); }
}
WindowLoad(init);
WindowUnload(shutdown);
function init()
{
onTimerFired();
}
function onTimerFired()
{
field = getElementById("Last5Songs");
if (field)
{
fetchMusicList("./script.php");
}
timerId = self.setTimeout("onTimerFired()", REFRESH_TIME);
}
function fetchMusicList(url)
{
if(window.XMLHttpRequest)
{
try
{
musicListRequester = new XMLHttpRequest();
}
catch(e)
{
musicListRequester = false;
}
}
else if (window.ActiveXObject)
{
try
{
musicListRequester = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
musicListRequester = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e)
{
musicListRequester = false;
}
}
}
if (musicListRequester)
{
musicListRequester.onreadystatechange=musicListFetched;
musicListRequester.open("GET", url);
musicListRequester.send(null);
}
}
function musicListFetched()
{
if (musicListRequester.readyState == 4 && musicListRequester.status == 200)
{
var output = "";
var songs = musicListRequester.responseXML.getElementsByTagName('playlist')[0].getElementsByTagName('song');
for (var i = 0; i < songs.length; i++)
{
root = songs[i];
var artist = root.getElementsByTagName("artist")[0].firstChild.nodeValue;
var song = root.getElementsByTagName("name")[0].firstChild.nodeValue;
var image = root.getElementsByTagName("image")[0].firstChild.nodeValue;
var rating = root.getElementsByTagName("rating")[0].firstChild.nodeValue;
var songid = root.getElementsByTagName("songid")[0].firstChild.nodeValue;
var totalvotes = root.getElementsByTagName("totalvotes")[0].firstChild.nodeValue;
output = output + (i+1) + ") " + artist + " - " + song + "- " + image + "- " + rating + "- " + songid + "- " + totalvotes + "";
output += ' <input type="checkbox" name="totalvotes" value="' + totalvotes +'" /><br />';
} document.getElementById("Last5Songs").innerHTML = output;
}
}
// -->
</script>
<td class="text_box" vAlign="top" bgColor="#ffffff" height="50" width="893">
<div id="Last5Songs" style="width: 888; height: 39">
</div>
</td>
</body>
</html>