This article describes the method of forced clicking ads in JavaScript. Share it for your reference. The details are as follows:
The JavaScript code for forced clicking on ads introduced here will take effect by clicking on the ad first and then the download address, or a certain part of the content will be displayed after clicking on the ad first. It is generally used for download sites or document information websites. Try not to use it as much as possible, otherwise the user experience of the website will be very poor!
Copy the code as follows:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Forced to click on the ad code</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<!--Add the following code between <head> and </head>-->
<script language="javascript">
var num = 2;
var mypage = '//www.VeVB.COM';
var pissoff = 'Click the link above to open me! ';
allow = Array();
allow[num] = 2;
function gotoit(link){
if (link != num){
allow[link] = 2;
} else {
for (i=1;i<=num;i++){
if (allow[i] != 2){
i = num + 1;
lemmeIn = 0;
} else {
lemmeIn = 1;
}
}
if (lemmeIn == 1){
window.location = mypage;
} else {
alert(pissoff);
}
}
}
//--->
</script>
</head>
<body>
<!--Add the following code between <body> and </body>-->
<p><a href="//www.VeVB.COM" target="_blank" onClick="gotoit(1)">This is an ad link</a></p>
<p><a href="javascript:gotoit(num)">Please click the link above before clicking me</a></p>
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.