1

I have been stuck on this for over one hour:

   if((document.referrer===undefined)){

  if(url_window_location=='http://www.lhttp://livecas.com/sandbox/andbox/'){
      event_google_analytics_referrer=document.referrer.toString(); 
         log("DOCUMENT REFERRER: cookie is set user_details: "+document.referrer);
        eraseCookie('user_details');
         setCookie('user_details',document.referrer,365); 
   }

    if(url_window_location=='hhttp://livecas.com/sandbox/e')
    {   
        eraseCookie('user_details');
        setCookie('landing_page_ref',"FBLND1",365);
        //   log("Cookie is set"); 
    }
 }

 else{

       if(url_window_location=='http://livecas.com/sandbox/'){
            eraseCookie('user_details');
         setCookie('user_details',"Direct",365); 
          log("Direct cookie is set");

          event_google_analytics_referrer="Direct";
      }
 }

If document.referrer is set/exists or whatever, i want it to execute the block in the if condition if not I want it the else condition. now it goes to the else condition no matter what

4

1 に答える 1

9

document.referrer常に存在します。空白(空の文字列)の場合があるだけです。

の代わりにif( document.referrer === undefined)、代わりに使用if(!document.referrer)してください。これは、すべての偽の値に対して実行されます。

于 2012-06-14T14:29:48.273 に答える