indexu.com

developer blog

Failed to load trackclick.js.php

Today a user report that the outgoing hits doesn’t work on portal_dir template.

A quick check:
1) footer.html

11
<script language="javascript" type="text/javascript" src="<%$tpl_base%>/trackclick.js.php"></script>

2) check whenever trackclick.js.php file exist in template folder.
3) check the link that count has proper “name” attribute

If everything look good, then it should work well.

However in this user case it doesn’t work well. Somehow trackclick.js.php never been loaded. When I rename to .js file, it work well. When I try to load from other template folder (komet or kosmos), then it work well. So it should be the file access permission, the .htaccess file. For me, .htaccess file seems good too. So I decide to do a quick fix for this installation.

1) edit footer.html to load trackclick.js (instead of .php file)

11
<script language="javascript" type="text/javascript" src="<%$tpl_base%>/trackclick.js.php"></script>

2) rename trackclick.js.php to trackclick.js
3) edit trackclick.js

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var base = "http://www.domainname.com";
 
var indexulinks = document.getElementsByTagName("a");
for(i = 0; i < indexulinks.length; i++) {
	if (indexulinks[i].name != '' && (indexulinks[i].name.indexOf("link") != -1 || indexulinks[i].name.indexOf("cat") != -1)) {
		indexulinks[i].onclick = indexu_click;
    indexulinks[i].oncontextmenu = indexu_click;
	}
}
 
function indexu_click() {
  if (document.images) {
    img = new Image();
    img.src = base+"/trackclick.php?id=" + this.name;
 
    var date = new Date();
    do {
      var curDate = null;
      curDate = new Date();
    }
    while(curDate-date < 300);
    date = null;
    curDate = null;
  }
  return true;
}
Previous post

Leave a Reply