Este artículo ilustra el método de JS para desaparecer automáticamente grandes anuncios deslizándose desde la esquina superior derecha de la página web. Compártelo para su referencia. El método de implementación específico es el siguiente:
Copie el código de la siguiente manera: <! 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">
<Evista>
<title> El gran efecto publicitario que desaparecerá automáticamente cuando la esquina superior derecha de la página web de JS se salga </title>
<meta http-oquiv = "content-type" content = "text/html; charset = gb2312">
<
<script type = "text/javaScript" lenguaje = "javaScript">
tiempo var = 500;
var w = 0;
función addcount ()
{
if (tiempo> 0)
{
tiempo--;
w = w+5;
}
demás
{
devolver;
}
if (w> 278) // ancho
{
devolver;
}
document.getElementById ("anuncios"). style.display = "";
document.getElementById ("anuncios"). style.width = w+"px";
setTimeOut ("addCount ()", 30);
}
window.onload = function showads ()
{
addCount ();
setTimeout ("noads ()", 3000); // tiempo de colmo
}
</script>
<script type = "text/javaScript" lenguaje = "javaScript">
var t = 198;
var n = 188; // altura
function noads ()
{
if (t> 0)
{
T--;
N = n-5;
}
demás
{
devolver;
}
if (n <0)
{
document.getElementById ("anuncios"). style.display = "Ninguno";
devolver;
}
document.getElementById ("anuncios"). style.width = n+"px";
setTimeOut ("noads ()", 30);
}
</script>
</ablo>
<Body>
<!-Agregue el siguiente código entre <body> y </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>
Espero que este artículo sea útil para la programación de JavaScript de todos.