当前位置:首页 > 代码 > 正文

js轮换广告代码(js轮换广告代码怎么用)

admin 发布:2022-12-19 18:50 111


今天给各位分享js轮换广告代码的知识,其中也会对js轮换广告代码怎么用进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

js或css实现滚动广告的几种方案

在触发js的scroll事件啊,可是我遇到的是真正不动的,我开始以为是FF上面才会这样,没想到IE6和IE7都有如此效果,不得不惊叹神奇了。

如是我就找出了如下神奇的代码:仅用CSS实现滚动效果~~

#fixed{position:fixed;}

div id="fixed"滚动/div

完了,就这个属性就搞定滚动了,真想骂人了。不过还没完呢,这个只支持火狐和IE7,我刚才说过IE6也可以的,只是IE6要实现就有点复杂了,

复制代码代码如下:!--[if IE]

style type="text/css"

* html #fixed{position:absolute;right:1px;top:expression_r(eval_r(document.body.height + 500));}

* html{overflow:hidden;}

* html body{height:100%;overflow:auto;}

* html #fixed{right:17px;top:5em;}

* html #fixed{right :1px;top :expression_r(eval_r(document.body.height + 500));}/style![endif]--

既然我的标题是实现滚动的N种方法的话,肯定不只是这两种了。好像CSS的还有其他写法,我就不一一列举了,我主要是想告诉大家比较常用的JS实现方式,我的网站有用到一段代码,也是网上找的,不过有个不好的地方就是它是相对顶部的,也就是你的网页高度不够就会出现拉不到底的情况,其实百度留言也会出现这种状况的,我就不多说了,先贴出来大家看看:复制代码代码如下:lastScrollY=0;

function heartBeat(){var diffY;if (document.documentElement document.documentElement.scrollTop)

diffY = document.documentElement.scrollTop;

else if (document.body)

diffY = document.body.scrollTopelse{}percent=.1*(diffY-lastScrollY);

if(percent0)percent=Math.ceil(percent);

else percent=Math.floor(percent);

document.getElementById("lovexin12").style.top=parseInt(document.getElementById("lovexin12").style.top)+percent+"px";

(document.getElementById("lovexin12").style.top)+percent+"px";

lastScrollY=lastScrollY+percent;}window.setInterval("heartBeat()",1);

有兴趣的话大家可以把上面的改成相对于底部,这样会好很多。

最近一直在看js库,比较感兴趣的jquery还是很不错的,所以呢~,现在再来贴一个用jquery来实现滚动的代码,比上面这个感觉要好很多。不过也只是个选择,没有必要可以不用,必竟jquery的代码也有几十KB的。

复制代码代码如下:$(document).ready(function(){

if($.browser.msie $.browser.version == 6) {

FollowDiv.follow();}});FollowDiv = {

follow : function(){

$('#cssrain').css('position','absolute');

js幻灯片广告切换代码

js幻灯片广告切换代码如下操作。

1、下载到的压缩包,上传到网站根目录下。

2、解压出来,复制index.html里面的主要代码,插入到网站项目想要放置的位置。

3、对插入的代码,根据自己需求对文字以及图片做适当的修改和替换,即可投入到自己网站中使用以及呈现。

求js滚动的广告图片代码

html

head

title广告滚动/title

script

var advInitTop=0;

var closeInitTop=0;

function init(){

advInitTop=document.getElementById("advLayer").style.pixelTop;

closeInitTop=document.getElementById("closeLayer").style.pixelTop;

}

function move(){

document.getElementById("advLayer").style.pixelTop=

advInitTop+document.body.scrollTop;

document.getElementById("closeLayer").style.pixelTop=

closeInitTop+document.body.scrollTop;

window.onscroll=move;

}

function closeMe( ) {

document.getElementById("closeLayer").style.display="none";

document.getElementById("advLayer").style.display="none"; }

window.onscroll=move ;

/script

/head

body onload="init()"

img src="images/top.jpg"

img src="images/content1.jpg"

img src="images/content2.jpg"

img src="images/foot.jpg"

div id="advLayer" style="position:absolute; left:16px;

top:129px; width:144px; height:95px; z-index:1;"

img src="images/left.jpg"

/div

div id="advLayer" style="position:absolute; right:16px;

top:129px; width:144px; height:95px; z-index:1;"

img src="images/right.jpg"

/div

div id="closeLayer" onclick="closeMe( )"

style="position:absolute;left:166px;top:132px;width:27px;

height:19px;z-index:2;"

img src="images/close.png" width="26" height="18"/div

/body

/html

JS轮播弹窗代码

//时间控制的广告代码

var cookie = {

ad0:30,//时间控制第一个广告30分钟轮播

ad1:60,//时间控制第二个广告60分钟轮播

ad_num : 2,

get_cookie : function(Name){var search = Name + "="; var returnvalue = "";if (document.cookie.length 0) {offset = document.cookie.indexOf(search);if (offset != -1) {offset += search.length;end = document.cookie.indexOf(";", offset);if (end == -1)end = document.cookie.length;returnvalue=unescape(document.cookie.substring(offset, end));}}return returnvalue;},

init : function(){

for(var i=0; icookie.ad_num; i++){

if(cookie.get_cookie('ppad_cookie_'+i)){

continue;

}else{

var Then = new Date();current_time = eval('cookie.ad'+i);Then.setTime(Then.getTime() + current_time*60*1000);document.cookie='ppad_cookie_'+i+'=1;expires='+ Then.toGMTString()+';path=/;';

switch(i){

case 0:

广告代码一 break;

case 1:

广告代码二 break;

}

break;

}

}

}

}

cookie.init();

//直接就放JS文件里面

JS广告代码怎么用啊?图片自动切换的那种。

试试这个图片切换

有12345数字一起切换

鼠标点一下数字会变换到另一张图片,不点就会自动换

里面有教程和源码

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轮换广告代码和js轮换广告代码怎么用的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/18534.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载