commit c6d37f9 code中文原文

Getting CNZZ Analytics to Pass W3C Validation

Author
Yujia Lin
Date
Reading time
1 min read

Translated from Chinese by Claude. Read the original

Just a quick note~ I was tinkering with my wordpress again, because the CNZZ analytics code isn’t standards-compliant~ so I had to modify it~ to get CNZZ to pass W3C validation.

Here’s the original code

1
<script src="http://s94.cnzz.com/stat.php?id=1979318&web_id=1979318" language="JavaScript"></script>

Then I changed it to the following

1
<script type="text/javascript" src='http://s94.cnzz.com/stat.php?id=1979318&web_id=1979318' language='JavaScript' charset='gb2312'></script>

Most analytics code has the following problems:

1.Every & in URLs and text has to be replaced with &amp

2.All attributes and tag names must be lowercase, and you need to specify the “type”, note the double quotes

3.Image img tags must have an alt attribute

4.Line breaks must use <br />

After carefully fixing these, it will pass validation

Esc

Keyboard shortcuts

Ctrl K /
Search and commands
j k
Next or previous post in a list
Enter
Open the selected post
h l
Older or newer post (on a post)
g h
Go to the log
g a
Go to the archive
g t
Go to tags
g s
Go to stats
t
Switch light or dark theme
r
Random post
?
Show this help