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...
Expand|Select|Wrap|Line Numbers
- 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;
- }
Expand|Select|Wrap|Line Numbers
- 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;
- }
Expand|Select|Wrap|Line Numbers
- 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