2012-11-20 25 views

回答

1

試試這個代碼:

<html> 
<head> 
</head> 
<body> 
<a href="javascript:void(0)" onclick="countTenClicks()">Click 10 times to open window 
</a> 
<script> 

    var counter = 0; 
    function countTenClicks() { 
     if (counter > 9) { 
      window.open('http://www.google.com'); 
     } 
     else { 
      counter++; 
     } 

    } 

</script> 

編輯

<html> 
<head> 
<title></title> 
</head> 
<body> 
<a href="javascript:void(0)" onclick="countTenClicks(this)" id='link1'>Click 10 times 
    to open window link1</a> <a href="javascript:void(0)" onclick="countTenClicks(this)" 
     id='link2'>Click 10 times to open window link2 </a> 
<script type="text/javascript"> 

var link1_counter=0; 
var link2_counter=0; 
/* 
    repeate for 10 links 

    var for each link 
*/ 
function countTenClicks(sender){ 

    var linkID = sender.id; 
switch(linkID) 
    { 
    case link1: 
    if (link1_counter>9) 
{ 
window.open('http://www.google.com'); 
} 
    else 
{ 
link1_counter++; 
} 
    break; 
case link1: 
    if (link2_counter>9) 
    { 
    window.open('http://www.google.com'); 
    } 
else 
{ 
link2_counter++; 
} 
    break; 
/* 
repeate for 10 links 
*/ 

default: 
code to be executed if n is different from case 1 and 2 
} 

} 

</script> 

+0

我們如何應用多於10個鏈接@Mahmoud –

+0

您的意思是說,如果您點擊任何10次以上的網頁,您希望擁有10個鏈接,它將打開網頁? –

+0

是的,這是對的我該如何申請。請訪問此網站: - http://putfreeadvertise.blogspot.in/如何將這個東西應用於我的廣告顯示圖像......... –

相關問題