この記事では、Webページの右上隅からスライドすることにより、大きな広告を自動的に消去するJSの方法を示しています。参照のためにそれを共有してください。特定の実装方法は次のとおりです。
次のようにコードをコピーします。<
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<Title> JS Webページの右上隅がスワイプされたときに自動的に消える大きな広告効果</title>
<meta http-equiv = "content-type" content = "text/html; charset = gb2312">
<! - <head>と</head> - >の間に次のコードを追加します
<script type = "text/javascript"言語= "javascript">
var time = 500;
var w = 0;
関数addcount()
{
if(time> 0)
{
時間 - ;
w = w+5;
}
それ以外
{
戻る;
}
if(w> 278)// width
{
戻る;
}
document.getElementById( "ads")。style.display = "";
document.getElementById( "ads")。style.width = w+"px";
setimeout( "addcount()"、30);
}
window.onload = function showads()
{
addcount();
setimeout( "noneads()"、3000); //ダンジの時間
}
</script>
<script type = "text/javascript"言語= "javascript">
var t = 198;
var n = 188; //高さ
function noneads()
{
if(t> 0)
{
t--;
n = n-5;
}
それ以外
{
戻る;
}
if(n <0)
{
document.getElementById( "ads")。style.display = "none";
戻る;
}
document.getElementById( "ads")。style.width = n+"px";
setimeout( "noneads()"、30);
}
</script>
</head>
<body>
<! - <body>と</body> - >の間に次のコードを追加します
<div id = "ads" style = "margin:auto; display; display:none; position:aspolute; width:200px; top:0px; right:0; height:200px; background-color:#d5282e; overflow:hidden; text-align:center;"> <p align = "center"> </p>
</div>
</body>
</html>
この記事がみんなのJavaScriptプログラミングに役立つことを願っています。