原生Js_实现广告弹窗
广告样式当页面加载后5s刷新在右下角

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Gary图片轮播</title>
<style type="text/css">
#ad{
width:300px;
height: 300px;
background-color:antiquewhite;
/*绝对定位放置到浏览器右下角,即使有下拉条时广告弹窗也不会改变位置*/
position: fixed;
bottom:0px;
right: 0px;
display: none;
}
</style>
<script type="text/javascript"> function init(){
setTimeout(showAd,2000)
} function showAd(){
var ad = document.getElementById("ad");
ad.style.display ="block";
} function closeAd(){
var ad = document.getElementById("ad");
ad.style.display ="none";
} </script> </head> <body onload="init()">
<div id="ad">
<button onclick="closeAd()">关闭</button>
</div>
</body>
</html>
Gary-图片轮播.html
实现过程
设置广告弹窗样式,将广告样式固定与页面右下角
<body onload="init()">
<div id="ad"> </div>
</body>
<style type="text/css">
#ad{
width:300px;
height: 300px;
background-color:antiquewhite;
/*绝对定位放置到浏览器右下角,即使有下拉条时广告弹窗也不会改变位置*/
position: fixed;
bottom:0px;
right: 0px;
/*display: none;*/
}
</style>

设置广告每隔5秒显示出来
function init(){
setTimeout(showAd,2000)
}
function showAd(){
var ad = document.getElementById("ad");
ad.style.display ="block";
}
添加Button按钮实现广告的关闭
<body onload="init()">
<div id="ad">
<button onclick="closeAd()">关闭</button>
</div>
</body>
function closeAd(){
var ad = document.getElementById("ad");
ad.style.display ="none";
}

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Gary图片轮播</title>
<style type="text/css">
#ad{
width:300px;
height: 300px;
background-color:antiquewhite;
/*绝对定位放置到浏览器右下角,即使有下拉条时广告弹窗也不会改变位置*/
position: fixed;
bottom:0px;
right: 0px;
display: none;
}
</style>
<script type="text/javascript"> function init(){
setTimeout(showAd,2000)
} function showAd(){
var ad = document.getElementById("ad");
ad.style.display ="block";
} function closeAd(){
var ad = document.getElementById("ad");
ad.style.display ="none";
} </script> </head> <body onload="init()">
<div id="ad">
<button onclick="closeAd()">关闭</button>
</div>
</body>
</html>
Gary-图片轮播.html
原生Js_实现广告弹窗的更多相关文章
- 原生JS实现各种经典网页特效——Banner图滚动、选项卡切换、广告弹窗等
在制作网页过程中,我们可能会遇到各种常用的经典网页特效,比如Banner图片滚动.选项卡循环播放.右下角广告弹窗.评论提交展示.选项动态增删.剪刀石头布小游戏等等等...是不是感觉都见到过这些场景.那 ...
- js广告弹窗
生活中我们经常遇到一些烦人的广告页面,比方说弹窗,悬浮等等各种广告.有的同事甚至都下一个屏蔽广告插件到浏览器上.这样就防止了广告的干扰. 但是我们学前端的必须是要知道广告弹窗这个做的过程,甚至是它的原 ...
- jQuery实现广告弹窗
首先设置一个固定的窗口位于右下角,效果如下: 代码: jQuery实现广告弹窗.html 之后将该窗口初始设为隐藏,通过代码实现3秒自动显示,5秒自动隐藏,其效果如下: <!DOCTYPE ht ...
- jquery.cookie广告弹窗点击关闭后一天弹一次
jquery.cookie广告弹窗点击关闭后一天弹一次 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&qu ...
- JQ广告弹窗&随机抽奖————JQ
1.JQ广告弹窗 <div id="flo"> <img src="image.jpeg"> </div> <scri ...
- 谷歌chrome浏览器www.tradeadexchange.com广告弹窗跳转劫持病毒
近期大量网友出现chrome浏览器被劫持的情况,表现如下: · 点击(访问)任意网站任意链接均有概率弹出www.tradeadexchange.com. · ...
- 原生 js 模拟 alert 弹窗
复制头部的 js 代码到你的 js 文件的任何地方,调用Chef.alert方法传入相应的参数即可并没有什么功能,只是一个提示的作用,可能样式比 alert 的弹窗好看点,css是写在js里的,只要你 ...
- css广告弹窗满屏跑
window.onload=function(){ //广告滚动 var oneInner = $('#divid')[0]; //定时器 var a1a = setInterval(moves,10 ...
- 原生js控制控制--弹窗的显示和隐藏
以防浪费大家的时间,还是先上效果图吧,满足您的需求就往下look吧. 重要知识点:点击其他地方,也就是除了小叉子之外的地方也能够关闭弹窗哦.代码已标红 html代码: <button id ...
随机推荐
- ArrayList,LinkedList,Vector区别.TreeSet,TreeSet,LinkedHashSet区别
ArrayList: 基于数组的数据结构,地址连续,一旦数据保存好了,查询效率比较高,但是因为其地址连续,所以增删数据需要移动数据,影响速度 内部数组长度默认为10,当需要扩容时,数组长度按1.5倍增 ...
- 搭建自己的框架WedeNet(三)
WedeNet2018.BussinessLogic-业务逻辑层:结构如下: 基类: using System; using System.Collections.Generic; using Sys ...
- python 的面试题总汇
函数作用域; LEGB : L>E>G>B L : local函数内部作用域 E : enclosing函数内部与内嵌函数之间 G : global全局作用域 B : build-i ...
- js定时器 离开当前页面任然执行的问题
今天在博客上看到有人问 js定时器-----离开当前页面原本匀速运动的div加速了,回到页面若干时间恢复匀速??? 他是js定时器控制一个盒子做旋转动画 离开页面后js还在执行 但是盒子这个dom却被 ...
- css,使两个在同一行内的display:inline-block的div顶部对齐。
两个都加上:vertical-align:top;
- redis的使用(Java使用Jedis客户端连接redis)
一.添加依赖 <dependency> <groupId>redis.clients</groupId> <artifactId>jedis&l ...
- apache启动错误 AH00072: make_sock: could not bind to address [::]:443 windows系统端口/进程查看
1. netstat -ano|findstr " 2. tasklist|findstr "
- python函数:函数使用原则、定义与调用形式
一.函数初始 二.函数的使用原则 三.函数的定义与调用形式 四.函数的返回值 五.函数参数的使用 一.函数初始 # 须知一: # 硬盘空间无法修改,硬盘中的数据更新都是用新的内容覆盖旧的内容 # 内存 ...
- Maximum Xor Secondary CodeForces - 281D (单调栈)
Bike loves looking for the second maximum element in the sequence. The second maximum element in the ...
- 第六章 组件 61 动画-小球动画flag标识符的作用分析
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...