Writing a very simple function today is only a summary.
The basic flow of clicks is this: at the point of the link, first go to a statistical address you set, and then redirect to the real address.
I'm using AJAX to implement this process. In order to realize the link and advertising public this function.
Let's talk about the background code section.
First is the link section, he is the background code generated HTML code as follows
_GoodLink1.Append("·<a href='" + dr["LJDZ"] + "' target='_blank' title='" + dr["LJMC"] + "' onclick=\"UpdateTraffs ('LINK_TAB','LJID'," + dr["LJID"] + ",'DJCS')\">").Append (dr["LJMC"]).Append("</a>");
Then is the advertisement part, the advertisement part is by the code generation dynamic JS again by the page references JS display advertisement, below is the key code;
sb.Append("' target='_blank' onclick=\\");sb.Append ("\"javascript:UpdateTraffs('AD_TAB','GGID'," + dv.Table.Rows[k] ["GGID"] + ",'DJCS')\\");sb.Append("\">
The most important part of this is the use of the variable, so as to ensure that in JS is onclick=\ "javascript:updatetraffs ' ad_tab ', ' Ggid ', 1, ' DJCS ') \" form
The key to the transfer of intermediate data parameters is JS code as follows
function UpdateTraffs(tabName,mainkey,keyValue,column)//要验证的控件ID,验证的结果, 验证的类型email|user
{
var http_request;
if (window.XMLHttpRequest)
{//对于Mozilla、Netscape、Safari等浏览器,创建XMLHttpRequest对象
http_request = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// 对于Internet Explorer浏览器,创建XMLHttpRequest
try
{
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{}
}
}
http_request.open("POST","/Function/Traffic.aspx? _tabName="+tabName+"&&_mainkey="+mainkey+"&&_keyValue="+keyValue+"&& _column="+column+"",false);
http_request.send();
}