原生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 ...
随机推荐
- shiro学习(一)
基础依赖: shiro-core,junit(因为在单元测试中) test.class public class AuthenticationTest { SimpleAccountRealm rea ...
- opencv3.3 CUDA 初学实例
//swap.cu #include "cuda_runtime.h" #include "device_launch_parameters.h" #inclu ...
- LeetCode 腾讯精选50题--数组中的第K个最大元素
好吧,不得不承认,书上看到的始终不是自己的,只有亲身时间过才会明白该怎么操作. 找数组中第K个最大元素,简而言之就是先排序,不论使用哪种算法,都需要先排序,确认位置,由于数组可以通过下标直接访问,所以 ...
- React学习——子组件给父组件传值
//子组件 var Child = React.createClass({ render: function(){ return ( <div> 请输入邮箱:<input onCha ...
- http://www.moext.com博客搬家到这里啦
1.原博客莫叉特用的是自己的域名http://www.moext.com,由于服务器在国外,访问不太稳定,SEO做得也很不好: 2.喜欢博客园的极简风格,目前来看广告量也在可接受范围: 3.一个偶然的 ...
- IntelliJ IDEA 接口类跳转到实现类及实现类跳转到接口
接口和实现类的互相跳转是使用IntelliJ IDEA过程中常用的操作,在此记录一下: 1.Service接口跳转到实现类 操作:在接口类的方法上使用快捷键Ctrl+Alt+B,或者点击下图所示位置 ...
- fastadmin 隐藏操作栏按钮
formatter: function (value, row, index) { var that = $.extend({}, this); $(table).data({"operat ...
- 从n个数里面找最大的两个数理论最少需要比较
答案是:n+logn-2 过程是这样的: 甲乙比甲胜出,丙丁比丙胜出,最后甲丙比较,甲胜出...容易得出找出最大数为n-1次. 现在开始找出第二大的数字:明显,第二大的数字,一定和甲进行过比较.... ...
- imx6ull增加qt5 qtserialbus库
meta-qt5库地址:https://code.qt.io/cgit/yocto/meta-qt5.git/ 1.在fsl-release-yocto/sources/meta-qt5/reci ...
- 【audition CC】将3分钟的歌曲无缝延长到15分钟