Page 1 of 1

Running script when loaded by AJAX

PostPosted: Wed Jun 28, 2006 10:21 pm
by asundli
Hi.

I use this function to execute/load script added by a Ajax request.

This works perfectly, and I can even call the javascript function loaded by ajax/innerHTML.

The question is what happens to the browsers memory use? I load the <script> tag into the head several times. maby 1000 if you do this long enough.



function executeScript(div)
{

var x = div.getElementsByTagName("script");
for(var i=0;i<x.length;i++)
{
eval(x[i].text);
var scriptTag = document.createElement('script');
scriptTag.innerHTML = x[i].text;
scriptTag.type = 'text/javascript';
var head = document.getElementsByTagName('head').item(0);
head.appendChild(scriptTag);
}
}

Any ideas?

Best regards
Alexander
www.keyteq.no