首先在cnzz上注冊賬號后,他會給你如下代碼:
<script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://"); document.write(unescape("%3Cspan id='cnzz_stat_icon_xxxxxxxxxx'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s19.cnzz.com/z_stat.php%3Fid%3D1252929438%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));</script>
這段js代碼的意思是:
根據當前頁面所使用的傳輸協議來定義變量cnzz_protocol,如果是https協議,則cnzz_protocol="https://",否則為="http://"。
document.write()這個命令簡單地打印指定的文本內容到頁面上。
unescape() 函數可對通過 escape() 編碼的字符串進行解碼。站長工具,我是在這里解碼的,大家可以百度“unescape解碼”,有很多在線解碼工具的。
通過unescape()函數解碼,我們可以得到:
"<span id='cnzz_stat_icon_1252929438'></span><script src='" + cnzz_protocol + "s19.cnzz.com/z_stat.php?id=xxxxxxxxxx&show=pic1' type='text/javascript'></script>"
他創建了一個span元素,添加了一個script。
這個script執行完畢后,頁面變成下面
<span id="cnzz_stat_icon_1252929438"> <a href="http://www.cnzz.com/stat/website.php?web_id=xxxxxxxxxx" target="_blank" title="站長統計"> <img src="http://icon.cnzz.com/img/pic1.gif" border="0" hspace="0" vspace="0"> </a> </span> <script src="http://s19.cnzz.com/z_stat.php?id=xxxxxxxxxx&show=pic1" type="text/javascript"></script> <script src="http://c.cnzz.com/core.php?web_id=xxxxxxxxxx&show=pic1&t=z" charset="utf-8" type="text/javascript"></script>