Hi,

I use a code to display the counter result and to refresh that value I actually refresh all the page, I'd like to refresh the script only without refreshing the full page but I don't know how to modify the code to make it work.
Here's the actual code using the page refresh:
<body bgcolor="#566079" align="center">
<font face="Verdana" size="1" color="#C0C0C0">
<script language="JavaScript" src="../cgi-bin/online/online.cgi?output=javascript"> </script> visitors online
</font>
</body>


And here's the code I'd like to see:
<head>
<script language="JavaScript">
function vonline()
TO BE REPLACED BY ?
</script>

</head>
<body onLoad="javascript:setInterval('vonline()',5000);" bgcolor="#566079" align="center">
<font face="Verdana" size="1" color="#C0C0C0">
<script language="JavaScript" src="../cgi-bin/online/online.cgi?output=javascript"> </script> visitors online TO BE REPLACED BY ?
</font>
</body>

Thank you for all help...
G.

First, you want to give your script tag an id: <script id="visitors" language="JavaScript" src="../cgi-bin/online/online.cgi?output=javascript"> </script> visitors online then, your vonline() method should look something like this:

function vonline()
{
    var scriptTag = document.getElementById('visitors');
    scriptTag.src = "../cgi-bin/online/online.cgi?output=javascript";
}

That should refresh the javascript without reloading the page.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.