js对联广告滚动代码可关闭,js对联广告滚动代码可关闭吗
更新:2022-11-18 20:40
本文目录一览:
- js网页两侧广告弹出滚动对联代码
- JS带关闭按钮随屏幕滚动的对联广告
- 可关闭两边飘浮对联广告代码jquery特效宽屏显示
- js 代码,随页面滚动而滚动的浮动广告效果(带关闭按钮)
- js浮动广告,如何加“关闭”按钮?
- 弹出广告js代码 广告置于右下角的解决方法
js网页两侧广告弹出滚动对联代码
方法一:浏览器打广告拦截,如果是IE浏览器你你可以使用工具菜单中的intelnet选项中的窗口阻止程序中的勾选上方法二:打开电脑管家-工具箱-广告过滤-开启弹窗广告过滤规则和网页广告过滤规则有效拦截流氓广告,去除广告打扰。
JS带关闭按钮随屏幕滚动的对联广告
jquery控制背景音乐开关与自动播放提示音的方法。分享给大家供大家参考。具体如下: 很多人初学网页制作时在网页中加入一段背景音乐,听到音乐响起的那一刻往往都会有一丝的成就感。 这里就为大家讲解如何使用js控制背景音乐播放与停止。具体如下:
一、jquery控制背景音乐开关
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http//"
html xmlns="http//" xml:lang="en"
head
script src="js/jquery.min.js"/script
script type="text/javascript"
//加载背景音乐,并自动播放
$('#bg_music').append('embed id="m_bg_music" loop=true volume="60" autostart=true hidden=true src="guoan.mp3" /');
$('#bg_music_btn').click(function(){
var state = $('#bg_music_btn').attr('state');
if(state == '1')//
{
$('#bg_music_btn').attr('state','0');
$('#bg_music_btn').html('打开背景音乐');
$('#m_bg_music').remove();
}else if(state == '0')
{
$('#bg_music_btn').attr('state','1');
$('#m_bg_music').remove();
$('#bg_music_btn').html('关闭背景音乐');
$('#bg_music').append('embed id="m_bg_music" loop=true volume="60" autostart=true hidden=true src="guoan.mp3" /');
}
});
/script
/head
body
!--控制播放--
div id="bg_music_btn" state='1'关闭背景音乐/div
!--背景音乐--
div id="bg_music"/div
/body
/html
以上介绍了jquery如何控制背景音乐开关的方法,接下来再进一步扩展。
二、JQuery自动播放提示音
最早对网站有自动提示音的功能,发现在Discuz论坛中出现。但是它有一个问题就是只支持flash,不支持HTML5,不明确最新版本中是否支持HTML5。 对于Discuz 7.2 版本中,提供了player.swf、pm_1.mp3、pm_2.mp3、pm_3.mp3,然后使用如下脚本来实现:
div id="soundplayerlayer" style="position:absolute;top:-100000px"/div
script type="text/javascript" reload="1"
function soundplayer(file) {
$('soundplayerlayer').innerHTML = AC_FL_RunContent('id', 'pmsoundplayer', 'name', 'pmsoundplayer', 'width', '0′, 'height', '0′, 'src', '{$boardurl}images/sound/player.swf', 'FlashVars', 'sFile={$boardurl}images/sound/pm_' + file + '.mp3′, 'menu', 'false', 'allowScriptAccess', 'sameDomain', 'swLiveConnect', 'true');
}
/script
可惜这个方法局限在flash,在苹果设备上可能就会遇到麻烦了。
HTML5开源播放器JPlayer支持自动播放提示音
JPlayer支持play事件触发自动播放提示音。
- 装载JPlayer到一个div层,例如#jplayer。
$(function() {
$("#jplayer").jPlayer({
swfPath: "http//",
ready: function () {
$(this).jPlayer("setMedia", {
mp3: "./resources/message.mp3"
});
},
supplied: "mp3"
});
});
body部分加入: <div id="jplayer"></div>
装载JQuery完成后,jplayer的div内容在支持swf的浏览器内变成:
<div id="jplayer" style="width: 0px; height: 0px;">
<img id="jp_poster_0" style="width: 0px; height: 0px; display: none;">
<object height="1" width="1" id="jp_flash_0" data="http//" type="application/x-shockwave-flash" style="width: 0px; height: 0px;">
<param name="flashvars" value="jQuery=jQueryid=jplayervol=0.8muted=false">
<param name="allowscriptaccess" value="always">
<param name="bgcolor" value="#000000">
<param name="wmode" value="opaque">
</object>
</div>
在支持HTML5的浏览器内变成:
<div id="jplayer" style="width: 0px; height: 0px;">
<img id="jp_poster_0" style="width: 0px; height: 0px; display: none;">
<audio id="jp_audio_0" preload="metadata" src="./resources/message.mp3"></audio>
</div>
完成装载后就是触发播放的事件了。 2. 触发播放提示音事件
$("#jplayer").jPlayer('play');
- 循环播放函数,每5秒播放一次提示音
function PlaySound() {
$("#jplayer").jPlayer('play');
setInterval("PlaySound()", 5000);
return true;
}
附录:
- 解决无法自动播放提示音的问题 如果在加载JQplayer后,立刻运行播放的触发事件,没有任何效果!具体是什么原因我也不太清楚,估计是因为音频文件没有加载上。
- 解决方法是让触发事件等待5秒中执行。
setTimeout("$('#jplayer').jPlayer('play')", 5000);
加载完页面,5秒后自动播放提示音。
可关闭两边飘浮对联广告代码jquery特效宽屏显示
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
#ad1,#ad2{
-webkit-transition: all .5s ease-out;
-moz-transition: all .5s ease-out;
-o-transition: all .5s ease-out;
transition: all .5s ease-out;
POSITION:absolute;
TOP:120px;
width:100px;
height:200px;
border:1px solid red;
}
#close1,#close2{
font-size:10px;
background:gray;
float:right;
}
#close1:hover,#close2:hover{cursor:pointer}
</style>
</head>
<body>
<div id="mm" style="height:2000px;background:#f5f5f5;width:500px"></div>
<DIV id="ad1" style='left:2px;'>
<div id="close1">关闭</div>
</DIV>
<DIV id="ad2" style='right:2px;'>
<div id="close2">关闭</div>
</DIV>
<script type="text/javascript" src="js/jquery.js" ></script>
<script language="JavaScript" type="text/javascript">
$("#close1").click(function(){ //关闭广告
$(this).parent().remove();
})
$("#close2").click(function(){
$(this).parent().remove();
})
document.onscroll=function(){ //滑动保持广告位置
$("#ad1").style.top=document.body.scrollTop+120+'px';
$("#ad2").style.top=document.body.scrollTop+120+'px';
};
</script>
</body>
</html>
js 代码,随页面滚动而滚动的浮动广告效果(带关闭按钮)
随滚动而滚动,css就可以实现,也就是固定在屏幕固定位置,用 position:fixed;
即可,关闭按钮可以用document.getElementById('').style.display='none';
即可,如
<div style="width:500px; height:200px; background-color:#F00;position:fixed;left:100px;top:200px;" id="test">
<button onclick="document.getElementById('test').style.display='none';">关闭</button>
</div>
其中left和top都是相对于屏幕的位置
js浮动广告,如何加“关闭”按钮?
解决方案的代码如下
function target_dis(){
var target=document.getElementById("yourDivName");
target.style.display="none";
}
然后在连接或者 按钮中 加入onclick="target_dis();"
即可
然后点击“关闭”按钮 就可以了关掉了
弹出广告js代码 广告置于右下角的解决方法
可关闭,可最小化,带点淡入淡出效果的右下角弹出广告; 参考如下:
<html>
<head>
<title>右下角广告代码</title>
<style type="text/css">
#msg_win{border:1px solid #A67901;background:#EAEAEA;width:300px;position:absolute;right:2;margin:0px;display:none;overflow:hidden;z-index:99;}
#msg_win .icos{position:absolute;top:2px;*top:0px;right:2px;z-index:9;}
.icos a{float:left;color:#833B02;margin:1px;text-align:center;text-decoration:none;font-family:webdings;}
.icos a:hover{color:#fff;}
#msg_title{background:#FECD00;border-bottom:1px solid #A67901;border-top:1px solid #FFF;border-left:1px solid #FFF;color:#000;height:25px;line-height:25px;text-indent:5px;}
#msg_content{margin:2px;width:300px;height:200px;overflow:hidden;}
</style>
</head>
<body>
<p style="height:1000px;"></p>
<div id="msg_win" style="display:block;top:490px;visibility:visible;opacity:1;">
<div class="icos">
<a id="msg_min" title="最小化" href="javascript:void 0">_</a>
<a id="msg_close" title="关闭" href="javascript:void 0">×</a>
</div>
<div id="msg_title">广而告之:</div>
<div id="msg_content">
<a href="" target="_blank">
<img src="" width="300" height="270" border="0"/>
</a>
</div>
</div>
</body>
</html>
<script language="javascript">
var Message={
set: function(){//最小化与恢复状态切换
var set=this.minbtn.status == 1?[0,1,'block',this.char[0],'最小化']:[1,0,'none',this.char[1],'恢复'];
this.minbtn.status=set[0];
this.win.style.borderBottomWidth=set[1];
this.content.style.display =set[2];
this.minbtn.innerHTML =set[3]
this.minbtn.title = set[4];
this.win.style.top = this.getY().top;
},
close: function(){//关闭
this.win.style.display = 'none';
window.onscroll = null;
},
setOpacity: function(x){//设置透明度
var v = x == 100 ? '': 'Alpha(opacity=' + x + ')';
this.win.style.visibility = x=0?'hidden':'visible';//IE有绝对或相对定位内容不随父透明度变化的bug
this.win.style.filter = v;
this.win.style.opacity = x / 100;
},
show: function(){//渐显
clearInterval(this.timer2);
var me = this,fx = this.fx(0, 100, 0.1),t = 0;
this.timer2 = setInterval(function() {
t = fx();
me.setOpacity(t[0]);
if (t[1] == 0) {clearInterval(me.timer2) }
},10);
},
fx: function(a, b, c){//缓冲计算
var cMath = Math[(a - b) > 0 ? "floor": "ceil"],c = c || 0.1;
return function() {return [a += cMath((b - a) * c), a - b]}
},
getY: function(){//计算移动坐标
var d = document,b = document.body, e = document.documentElement;
var s = Math.max(b.scrollTop, e.scrollTop);
var h = /BackCompat/i.test(document.compatMode)?b.clientHeight:e.clientHeight;
var h2 = this.win.offsetHeight;
return {foot: s + h + h2 + 2+'px',top: s + h - h2 - 2+'px'}
},
moveTo: function(y){//移动动画
clearInterval(this.timer);
var me = this,a = parseInt(this.win.style.top)||0;
var fx = this.fx(a, parseInt(y));
var t = 0 ;
this.timer = setInterval(function() {
t = fx();
me.win.style.top = t[0]+'px';
if (t[1] == 0) {
clearInterval(me.timer);
me.bind();
}
},10);
},
bind:function (){//绑定窗口滚动条与大小变化事件
var me=this,st,rt;
window.onscroll = function() {
clearTimeout(st);
clearTimeout(me.timer2);
me.setOpacity(0);
st = setTimeout(function() {
me.win.style.top = me.getY().top;
me.show();
},600);
};
window.onresize = function (){
clearTimeout(rt);
rt = setTimeout(function(){me.win.style.top = me.getY().top},100);
}
},
init: function(){//创建HTML
function $(id) {return document.getElementById(id)};
this.win=$('msg_win');
var set={minbtn: 'msg_min',closebtn: 'msg_close',title: 'msg_title',content: 'msg_content'};
for (var Id in set) {this[Id] = $(set[Id])};
var me = this;
this.minbtn.onclick = function() {me.set();this.blur()};
this.closebtn.onclick = function() {me.close()};
this.char=navigator.userAgent.toLowerCase().indexOf('firefox')+1?['_','::','×']:['0','2','r'];//FF不支持webdings字体
this.minbtn.innerHTML=this.char[0];
this.closebtn.innerHTML=this.char[2];
setTimeout(function() {//初始化最先位置
me.win.style.display = 'block';
me.win.style.top = me.getY().foot;
me.moveTo(me.getY().top);
},0);
return this;
}
};
Message.init();
</script>