Hello,
I actually use a counter on a webpage (This is an external script that reads and increments a value - It actually works)
To do it, I use an inline javascript but I would like to unify the entire page and call that counter directly in the external Javascript that manages the whole site.
Here's the actual code...
and here an "idea" of my request...
I also tried a piece of code using this method...
That works partially: in IE there's no result and in Firefox it finds,increment s and displays the value but then it's impossible to continue using the page, it seems never finishing loading, even reload or refresh don't work, just close the webpage and open a new one is possible.
I asked a lot of people but no one seems to find a solution.
Does someone have an idea on how to proceed ?
Thanks in advance...
Gino
I actually use a counter on a webpage (This is an external script that reads and increments a value - It actually works)
To do it, I use an inline javascript but I would like to unify the entire page and call that counter directly in the external Javascript that manages the whole site.
Here's the actual code...
Code:
HTML
<body onLoad=gen_hits()>
...
<span id='hits'></span><SCRIPT language="JavaScript" SRC="http://www.mycompany.com/cgi-bin/counterdir/otherdir/counter"></SCRIPT>
...
</body>
EXTERNAL JAVASCRIPT (ini.js)
var hits="HITS ";
function gen_hits() {
document.getElementById("hits").innerHTML=hits;
}
Code:
HTML
<body onLoad=gen_hits()>
...
<span id='hits'></span>
...
</body>
EXTERNAL JAVASCRIPT
var hits="HITS " + <SCRIPT language="JavaScript" SRC="http://www.mycompany.com/cgi-bin/counterdir/otherdir/counter"></SCRIPT>;
function gen_hits() {
document.getElementById("hits").innerHTML=hits;
}
Code:
function setInnerHTMLAndExecScript (element, html) {
var newElement = element.cloneNode(false);
newElement.innerHTML = html;
element.parentNode.replaceChild(newElement, element);
}
function gen_hits() {
var myHtml = '<script type="text\/javascript" SRC="http://www.mycompany.com/cgi-bin/counterdir/otherdir/counter"><\/script>';
myHtml.type = 'text/javascript';
setInnerHTMLAndExecScript(document.getElementById('hits'),myHtml);
}
I asked a lot of people but no one seems to find a solution.
Does someone have an idea on how to proceed ?
Thanks in advance...
Gino
Comment