penguine Posted August 14, 2008 Share Posted August 14, 2008 Hi How can setInterval function be added to head element. i want setInterval('checkstat()', 2000) to be created dynamically.i tried var head=document.getElementById('head'); var newscript = document.createElement('script'); newscript .type = 'text/javascript'; newscript .setInterval=function(){'checkstat()', 2000}; head.appendChild(newscript ); but it seems to be not working. Link to comment Share on other sites More sharing options...
Ingolme Posted August 14, 2008 Share Posted August 14, 2008 I think you're trying to do this: var head=document.getElementByTagName('head')[0]; var newscript = document.createElement('script');newscript.type = 'text/javascript'; newscript.appendChild(document.createTextNode("setInterval('checkstat()', 2000)");head.appendChild(newscript ); But why create it dynamically? I still how doubts on if this will work, since once the browser finishes loading the head it most likely won't look back there again. Link to comment Share on other sites More sharing options...
penguine Posted August 22, 2008 Author Share Posted August 22, 2008 Thanks Ingolme, Its working and every 2 second its fires up checkstat function Link to comment Share on other sites More sharing options...
Kingy Posted August 22, 2008 Share Posted August 22, 2008 So you just want your site to update it's stats by itself right. I'm guessing you got something like a counter. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.