2017-10-27 10 views
-2

클릭 수에 추가 요즘 인기가 있지만 각 페이지에서 첫 번째 클릭으로 다른 웹 페이지에 맞춤 주소를 추가하고 두 번째 클릭으로 사용자를 목적지로 이동시키는 코드와 같은 스크립트를 만들고 싶습니다. 샘플 온 클릭 광고 코드어디서나 첫 번째 클릭을 리디렉션하고 두 번째 클릭하여 목적지로 이동하는 방법?

<script type='text/javascript' src='//vebadu.com/apu.php?zoneid=1415303'></script> 

답변

0

      //set href for all links=>stackoverflow 
 
$('a').each(function(){ 
 
    \t $(this).attr('href','https://stackoverflow.com'); 
 
}); 
 

 
var click_counter=0;    //counter of click 
 
$('a').click(function(){ 
 
    setTimeout(function(){   //timeout for open link 
 
    \t  click_counter++;    //first click => 1 
 
    \t  if(click_counter==1){ 
 
    \t \t  $('a').each(function(){ 
 
    \t \t        //replace all hrefs 
 
    \t \t \t  var second_link=$(this).attr('second-link'); 
 
    \t \t \t  $(this).attr('href', second_link); 
 
    \t \t  }); 
 
    \t  } 
 
    \t },500); 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 

 

 

 
<a href="" target="_blank" second-link="https://www.yahoo.com">yahoo</a><br> 
 
<a href="" target="_blank" second-link="https://www.wikipedia.org">wikipedia</a><br> 
 
<a href="" target="_blank" second-link="https://www.amazon.com">amazon</a><br> 
 
<a href="" target="_blank" second-link="https://www.gm.com">General Motors</a><br>

아래에 주어진