This article illustrates the method of JS to automatically disappear large advertisements by sliding out of the upper right corner of the web page. Share it for your reference. The specific implementation method is as follows:
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>The large advertising effect that will automatically disappear when the upper right corner of the js web page is swiped out</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<!--Add the following code between <head> and </head>-->
<script type="text/javascript" language="javascript">
var time = 500;
var w = 0;
function addCount()
{
if(time>0)
{
time--;
w = w+5;
}
else
{
return;
}
if(w>278)//width
{
return;
}
document.getElementById("ads").style.display = "";
document.getElementById("ads").style.width = w+"px";
setTimeout("addCount()",30);
}
window.onload = function showAds()
{
addCount();
setTimeout("noneAds()",3000);//Danging time
}
</script>
<script type="text/javascript" language="javascript">
var T = 198;
var N = 188;//Height
function noneAds()
{
if(T>0)
{
T--;
N = N-5;
}
else
{
return;
}
if(N<0)
{
document.getElementById("ads").style.display = "none";
return;
}
document.getElementById("ads").style.width = N+"px";
setTimeout("noneAds()",30);
}
</script>
</head>
<body>
<!--Add the following code between <body> and </body>-->
<div id="ads" style="margin:auto;display:none;position:absolute;width:200px;top:0px;right:0;height:200px;background-color:#d5282e;overflow:hidden;text-align:center;"><p align="center">Wulin.com</a>丨This special effect is collected from the Internet for interest only and is not for commercial purposes. </p>
</div>
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.