2013-02-12 4 views
0

Может кто-то помочь мне понять процесс в следующей ссылке, особенно часть внутри OnClick:что это.href.substr (23) делает для процесса трассировки события с GA?

<a href="http://www.example.com/files/download/files.php?file=my_file.doc" onClick="_gaq.push(['_trackEvent', 'Downloads', 'DOC', this.href.substr(23)]); fn12_reminder(this,''); return false;" rel="nofollow"> 

Я понимаю, что это просто GA процесс даже отслеживать, но то, что я не могу понять, это последняя часть this.href.substr(23) я не могу выяснить, что это на самом деле делает во всем процессе?

сценарий JS загружается в заголовке имеет следующий характер (я отправляю его в полном объеме, так что кто-то с опытом может обнаружить связь, если таковая существует):

var functions = true; 
function fn12_custom_display_notice(theNotice,theClass){ 
    if(theClass!=''){ 
     jQuery("#user-notice").removeClass(); 
     jQuery("#user-notice").addClass(theClass); 
     } 
     jQuery("#user-notice").html(theNotice).animate({width:'toggle'},250).delay(3000).animate({width:'toggle'},250); 
     } 
function fn12_custom_display_reminder(theHTML,theDownloadLink){if(typeof jQuery.ui!='undefined'){$("#dialog").attr("title","Please help spread the word").html(theHTML);$("#dialog").dialog({modal:true,width:375,buttons:{"Continue to Download":function(){$(this).dialog("close");window.location=theDownloadLink;}}});}else{window.location=theDownloadLink;}} 
function fn12_custom_reminder(aelem,topic){theLink=$(aelem).attr("href");$.ajax({type:"POST",url:"/db/ajax.php",data:"action=reminder&thepath="+theLink+"&topic="+topic,dataType:"json",error:function(){window.location=theLink;},success:function(msg){if(msg.status==1)fn12_custom_display_reminder(msg.html,theLink);else{fn12_custom_display_notice(msg.message,"error");}}});} 
function fn12_custom_gplus_callback(theObject){if(theObject.state=='on'){fn12_custom_display_notice("Big thanks!!!",'success');}} 

/* jquery_cookie.js Copyright (c) 2006 Klaus Hartl (stilbuero.de), Dual licensed under the MIT and GPL licenses */ 
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'||(name&&typeof name!='string')){if(typeof name=='string'){options=options||{};if(value===null){value='';options.expires=-1;} 
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;} 
expires='; expires='+date.toUTCString();} 
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=name+'='+encodeURIComponent(value)+expires+path+domain+secure;}else{for(var n in name){jQuery.cookie(n,name[n],value||options);}}}else{var returnValue={};if(document.cookie){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(!name){var nameLength=cookie.indexOf('=');returnValue[cookie.substr(0,nameLength)]=decodeURIComponent(cookie.substr(nameLength+1));}else if(cookie.substr(0,name.length+1)==(name+'=')){returnValue=decodeURIComponent(cookie.substr(name.length+1));break;}}} 
return returnValue;}}; 

Любая помощь является весьма apciciated

ответ

1

В вашем примере this.href.substr(23) равен files/download/files.php?file=my_file.doc, это просто URL-адрес, связанный с элементом a.

  • this относится к текущему объекту, в a элемента.
  • href относится к атрибуту элемента.
  • substr(23) принимает подстроку, начинающуюся с 23-го символа, для удаления протокола и имени домена.
+0

Спасибо за ваш быстрый ответ. Следующий вопрос: есть ли сценарий js, который я опубликовал, имеет к этому отношение? – AlexB

+0

Я не смотрел ваш полный ответ перед публикацией, так что теперь все это кристально ясно. – AlexB

Смежные вопросы