2017-12-22 9 views
0

애드 센스는 광고주에게 아무런 가치가없는 페이지에 광고가 표시되므로 계정을 제한합니다 (로그인 페이지). 나는 그것이 해당 페이지에서 실행되지 않도록 index.php를에 배치됩니다 애드 센스 코드를 제외하려고하지만 Uncought 구문 에러를 얻고있다 : 입력의 예기치 않은 끝을 콘솔에 I가 재 작성애드 센스 코드 실행에서 특정 페이지 제외

<script> 
    $(document).ready(function() { 
     if (window.location.pathname !== '/index.php/pl/edytuj-profil?view=login') { 
      (adsbygoogle = window.adsbygoogle || []).push({ 
       google_ad_client: "ca-pub-4673232933311358", 
       enable_page_level_ads: true 
      }); 
     } 
    </script> 

원본 코드를 이 :

<script> 
    (adsbygoogle = window.adsbygoogle || []).push({ 
    google_ad_client: "ca-pub-4673232933311358", 
    enable_page_level_ads: true 
    }); 
</script> 

감사의 말. enter image description here

답변

0

첫 줄을 올바르게 닫지 않았습니다. 그것은해야한다 :

$(document).ready(function() { 
    if (window.location.pathname !== '/index.php/pl/edytuj-profil?view=login') { 
     (adsbygoogle = window.adsbygoogle || []).push({ 
      google_ad_client: "ca-pub-4673232933311358", 
      enable_page_level_ads: true 
     }); 
    } 
}) 
0

당신이 PHP에서 이것을 사용하는, 당신은 당신의 페이지 확인을하고 해당 페이지에 모두 애드 센스 코드를 생략 PHP를 활용할 수 있습니다. 이를 수행하는 방법은 사용중인 환경에 따라 다릅니다. 아주 기본적인 예 :

$actual_link = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; 

if (strpos($actual_link, 'view=login') !== false) { 
    echo "<script> 
      (adsbygoogle = window.adsbygoogle || []).push({ 
      google_ad_client: 'ca-pub-4673232933311358', 
      enable_page_level_ads: true 
      }); 
      </script>"; 
} 
+0

그래, 나는 다음과 같은 코드로 같은 생각 내 질문을 게시 후 : \t

+0

내 대답이 도움이되었다고 생각하면 [내 대답을 수락 할 수 있습니다] (http://meta.stackexchange.com/a/5235). – herrbischoff

+0

해결책은 좋지만 실제 질문에는 답하지 않습니다. 케빈이 대답했습니다. –