Podobně jako NAVRCHOLU.cz
skript pro měření návštěvnosti je nutné přepsat
pro podporu application/xhtml+xml, u TOPLIST.cz je
to to samé.
Výsledek byl testován a funguje v Opeře 7.60 TP4, Firefoxu 1.0
(application/xhtml+xml), a rovněž v MSIE 6.0 (text/html).
Zde je kód pro toplist.js:
// (c) Radek HULAN, http://hulan.cz/
// This work is licensed under the Creative Commons Attribution License.
//
// TOPLIST.cz statistics that works under XHTML 1.1 served with
// MIME type application/xhtml+xml as well as text/html MIME type.
//
//
// Usage - place this in your XHTHML 1.1 code:
//
//
//
// helper functions
var isXHTML;
function createNewEle(ele){
if(isXHTML)
return document.createElementNS('http://www.w3.org/1999/xhtml', ele);
else
return document.createElement(ele);
};
function toplist(){
var ele=document.getElementById('toplist');
if (!ele) return;
isXHTML=/html\:/.test(document.getElementsByTagName('body')[0].nodeName);
// toplist.cz id from title
var id=parseInt(ele.getAttribute('title'));
if (!id) alert('TITLE attribute does not contain your TOPLIST.cz ID!');
var img=ele.getElementsByTagName('img');
// set new A attributes
ele.href='http://toplist.cz/stat/'+id;
ele.setAttribute('title','TOPLIST.cz');
// create IMG
var img=ele.appendChild(createNewEle('img'));
img.setAttribute('alt','TOPLIST.cz');
img.setAttribute('style','width:88px;height:120px');
img.setAttribute('src','http://toplist.cz/count.asp?id='+id
+'&logo=bc'
+'&http='+escape(document.referrer)
+'&wi='+escape(window.screen.width)
+'&he='+escape(window.screen.height)
+'&cd='+escape(window.screen.colorDepth)
+'&t='+escape(document.title));
}
toplist();
Použití skriptu:
Vložte tento kód do Vašeho XHTML:
Pochopitelně, číslo 64941 upravte na Vaše číslo počítadla. Kód je pochopitelně napsaný tak, že funguje i při vypnutém JavaScriptu.