js 技巧 (十)广告JS代码效果大全 【2】
2.[鼠标感应]
与前面一个代码不同的是,当鼠标移动到广告图片上是可以感应显示另外设置好的广告大图效果,下面就是实现效果所需代码:
function bigshow(){
document.all.div_250.style.visibility = 'visible';
document.all.div_80.style.visibility = 'hidden';
}
function bighide(){
document.all.div_80.style.visibility = 'visible';
document.all.div_250.style.visibility = 'hidden';
}
var ad_80= new Array(1);
var ad_250= new Array(1);
ad_80[0]="<a href=http://www.dfeng.net target=_blank><img src=/skin/adv43/ad/ad_ad.gif border=0></a>";
ad_250[0]="<a href=http://www.dfeng.net target=_blank><img src=/skin/adv43/ad/ad_ad2.gif border=0></a>";
var imgheight;
var fubioleft;
window.screen.width>800 ? fubioleft=15:fubioleft=15
document.write('<DIV id=floater_left >');
ad_now = new Date();
ad_id= ad_now.getSeconds() %1
var adhead1="<div id=div_80 style='position:absolute; width:95px; height:62px; z-index:12' onMouseOver=bigshow();>";
var adhead2="</div><div id=div_250 style='position:absolute; visibility: hidden; z-index:13;width: 80; height: 60' onMouseOut=bighide();>";
//var adhead1="<div id=div_80 style='position:absolute; width:95px; height:62px; z-index:20' onMouseOut='//MM_showHideLayers(""div_250"","""",""hide"")' onMouseOver='MM_showHideLayers(""div_250"","""",""show"")'>";
//var adhead2="</div><div id=div_250 style='position:absolute; z-index:21;visibility: hidden; width: 80; height: 60' onMouseOver='MM_showHideLayers(""div_250"","""",""show"")' onMouseOut='MM_showHideLayers(""div_250"","""",""hide"")'>";
document.write(adhead1+ad_80[ad_id]+adhead2+ad_250[ad_id]+"</div>");
document.write ("</div>");
self.onError=null;
currentX = currentY = 0;
whichIt = null;
lastScrollX = 0; lastScrollY = 0;
NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1: 0;
function heartBeat() {
if(IE) {
diffY = document.body.scrollTop;
diffX = document.body.scrollLeft; }
if(NS) {
diffY = self.pageYOffset; diffX = self.pageXOffset; }
if(diffY != lastScrollY) {
percent = .5 * (diffY - lastScrollY);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.floater_left.style.pixelTop += percent;
if(NS) document.floater_left.top += percent;
lastScrollY = lastScrollY + percent;
}
if(diffX != lastScrollX) {
percent = .5 * (diffX - lastScrollX);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.floater_left.style.pixelLeft += percent;
if(NS) document.floater_left.left += percent;
lastScrollX = lastScrollX + percent;
}
}
if(NS || IE) action = window.setInterval("heartBeat()",1);var ad_80= new Array(1);
var ad_250= new Array(1);
ad_80[0]="<a href=http://www.dfeng.net target=_blank><img src=/skin/adv43/ad/ad_ad.jpg border=0></a>";
ad_250[0]="<a href=http://www.dfeng.net target=_blank><img src=/skin/adv43/ad/ad_ad.jpg border=0></a>";
var imgheight;
var fubioleft;
window.screen.width>800 ? fubioleft=15:fubioleft=15
document.write('<DIV id=floater_right >');
ad_now = new Date();
ad_id= ad_now.getSeconds() %1
function myload()
{
if (navigator.appName == "Netscape")
{
document.div_right_80.pageX=+window.innerWidth-130;
document.div_right_250.pageX=+window.innerWidth-300;
mymove();
}
else
{
div_right_80.style.left=document.body.offsetWidth-130;
div_right_250.style.left=document.body.offsetWidth-300;
mymove();
}
}
function mymove()
{
if(document.ns)
{
document.div_right_80.left=pageXOffset+window.innerWidth-130;
document.div_right_250.left=pageXOffset+window.innerWidth-300;
setTimeout("mymove();",20)
}
else
{
div_right_80.style.left=document.body.scrollLeft+document.body.offsetWidth-145;
div_right_250.style.left=document.body.scrollLeft+document.body.offsetWidth-300;
setTimeout("mymove();",20)
}
}
var adhead1="<div id=div_right_80 style='position:absolute; width:95px; height:60px; z-index:12' onMouseOver=bigshow_right();>";
var adhead2="</div><div id=div_right_250 style='position:absolute; visibility: hidden; z-index:13;width: 250; height: 250' onMouseOut=bighide_right();><div align=right>";
document.write(adhead1+ad_80[ad_id]+adhead2+ad_250[ad_id]+"</div></div>");
myload()
document.write ("</div>");
self.onError=null;
currentX_right = currentY_right = 0;
whichIt_right = null;
lastScrollX_right = 0; lastScrollY_right = 0;
NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1: 0;
function heartBeat_right() {
if(IE) {
diffY_right = document.body.scrollTop;
diffX_right = document.body.scrollLeft; }
if(NS) {
diffY_right = self.pageYOffset; diffX_right = self.pageXOffset; }
if(diffY_right != lastScrollY_right) {
percent_right = .5 * (diffY_right - lastScrollY_right);
if(percent_right > 0) percent_right = Math.ceil(percent_right);
else percent_right = Math.floor(percent_right);
if(IE) document.all.floater_right.style.pixelTop += percent_right;
if(NS) document.floater_right.top += percent_right;
lastScrollY_right = lastScrollY_right + percent_right;
}
if(diffX_right != lastScrollX_right) {
percent_right = .5 * (diffX_right - lastScrollX_right);
if(percent_right > 0) percent_right = Math.ceil(percent_right);
else percent_right = Math.floor(percent_right);
if(IE) document.all.floater_right.style.pixelLeft += percent_right;
if(NS) document.floater_right.left += percent_right;
lastScrollX_right = lastScrollX_right + percent_right;
}
}
if(NS || IE) action = window.setInterval("heartBeat_right()",1);
function bigshow_right(){
document.all.div_right_250.style.visibility = 'visible';
document.all.div_right_80.style.visibility = 'hidden';
}
function bighide_right(){
document.all.div_right_80.style.visibility = 'visible';
document.all.div_right_250.style.visibility = 'hidden';
}document.write('');
document.write('');
document.write('');
出处至:http://xiaobingandxiaoer.iteye.com/blog/1917696
js 技巧 (十)广告JS代码效果大全 【2】的更多相关文章
- js 技巧 (十)广告JS代码效果大全 【3】
3.[允许关闭] 与前面两个代码不同的是,广告图下方增加了一个图片按纽,允许访客点击关闭广告图片,下面文本框中就是实现效果所需代码: var delta=0.015; var coll ...
- js 技巧 (十)广告JS代码效果大全 【1】
广告JS代码效果大全 1.[普通效果] 现在很多网站广告做的如火如荼,现在我就来介绍一下常见的对联浮动广告效果的代码使用方法,介绍的这种效果,在1024*768分辨率下正常显示,在800*60 ...
- Eclipse用法和技巧十:显示代码outline
在一个文件中快速找到某一个方法或者某一个作用域,可以使用 Ctrl+O或者Ctrl+F3,快速显示当前代码的outline,进行快速查找.效果如下: 这里主要是补充一些后续操作,能更加方 ...
- 常用JS技巧[转]
作者:72妃 事件源对象 event.srcElement.tagName event.srcElement.type 捕获释放 event.srcElement.setCapture(); even ...
- js 表单验证控制代码大全
js表单验证控制代码大全 关键字:js验证表单大全,用JS控制表单提交 ,javascript提交表单:目录:1:js 字符串长度限制.判断字符长度 .js限制输入.限制不能输入.textarea 长 ...
- js div浮动层拖拽效果代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Js弹性漂浮广告代码
<html><head><meta http-equiv="Content-Type" content="text/html; charse ...
- JS实现简单的运行代码 & 侧边广告
/* JS实现简单的运行代码功能 */<!doctype html> <html> <head> <meta charset="utf-8" ...
- js页面跳转参考代码大全
整理一下JS页面跳转参考代码 第一种: <script language=/"javascript/" type=/"text/javascript/&qu ...
随机推荐
- HDU5996:dingyeye loves stone
题目链接:dingyeye loves stone 题意:给出一棵树,树上的每个节点都有石子若干, 两人博弈,每次操作都可以把任意节点的任意石子数转移到它的父亲节点, 若无法操作则输,给出树上的节点及 ...
- Luogu P1119 灾后重建 【floyd】By cellur925
题目传送门 这道题我们很容易想到对于每次询问,都跑一遍最短路(spfa,虽然他已经死了).只需在松弛的时候加入当前相关的点是否已经修好的判断,果不其然的TLE了4个点. (然鹅我第一次用spfa跑的时 ...
- apicloud运行机制
1 首先在官网apicloud中,创建项目生成config.xml文件,预设风格. 2 将config.xml文件放在项目跟目录中,Vue项目,必须先打包生产dist文件, 3 本地或者云编译(官方工 ...
- 关于Http的小常识(转载,仅供参考)
HTTP请求头提供了关于请求,响应或者其他的发送实体的信息.HTTP的头信息包括通用头.请求头.响应头和实体头四个部分.每个头域由一个域名,冒号(:)和域值三部分组成. 通用头标:即可用于请求,也可用 ...
- LightOj 1197 Help Hanzo (区间素数筛选)
题目大意: 给出T个实例,T<=200,给出[a,b]区间,问这个区间里面有多少个素数?(1 ≤ a ≤ b < 231, b - a ≤ 100000) 解题思路: 由于a,b的取值范围 ...
- Windows7运行无法记录历史命令问题解决
Windows7运行无法记录历史命令,每次都需要手动敲命令,解决方法如下: 1.任务栏中右键,选择"属性"菜单: 2.在弹出框中的"[开始]菜单"选项卡的隐私区 ...
- border-1px的实现(stylus)
当样式像素一定时,因手机有320px,640px等.各自的缩放比差异,所以设备显示像素就会有1Npx,2Npx.为保设计稿还原度,解决就是用media + scale. // stylus语法 bor ...
- [转]Android项目快速开发框架探索(Mysql + OrmLite + Hessian + Sqlite)
前言 结合之前所用的ormlite和hessian,再加上SAE已经支持JAVA,把服务端切换到JAVA,也就有了本文.使用hessian来做数据传输,ormlite来实现客户端与服务端的数据存储,极 ...
- vim插件minibuf配置
1.去下载网站下载minibufexpl.vim文件放入到~/vim/plugins中,有的系统路径是~/.vim/plugins; 下载网址如下 https://www.vim.org/script ...
- 绿化VSCode
通过啃源码, 终于找到了解决办法, 设置环境变量: VSCODE_APPDATA=C:\Program Files\VSCode\UserData VSCODE_EXTENSIONS=%VSCODE_ ...