javascript 浮动广告 代码 类DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>HTML> HEAD> TITLE> javascript 浮动广告代码 TITLE> HEAD> BODY> position:absolute; –>div id=sign1 style=cursor:hand;>a href=http://www.16
大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。 Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺
<!
DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”
>
<
HTML
>
<
HEAD
>
<
TITLE
>
javascript 浮动广告代码
</
TITLE
>
</
HEAD
>
<
BODY
>
<!–
position:absolute;
–>
<
div
id
=’sign1′
style
=’cursor:hand;’
>
<
a
href
=’http://www.163.com/’
><
img
border
=0
src
=”http://images.163.com/homepage/logo.gif”
/></
a
>
</
div
>
<
div
id
=’sign2′
>
<
a
href
=’http://www.fleaphp.org/’
><
img
border
=0
src
=”http://www.fleaphp.org/files/fleaphp_logo.gif”
/></
a
>
</
div
>
<
div
id
=’sign3′
>
<
a
href
=’http://www.ynjob.net/’
><
img
border
=0
src
=”http://ynjob.net/images/sm_logo.gif”
/>
</
div
>
<
script
language
=”JavaScript ”
>
…
// 使用方法 var tmpObj1 = new GggMoveSign( “ sign1 “ ); // 设定要移动的对象 tmpObj1.MoveTo( 150 , 50 ); // 从哪里开始移动 tmpObj1.Run( 50 , 10 ); // tmpObj1.Run(每隔多少时间移动一次,每次移动几个像素); var tmpObj2 = new GggMoveSign( “ sign2 “ ); tmpObj2.MoveTo( 300 , 350 ); // 从哪里开始移动 tmpObj2.Run( 300 ); var tmpObj3 = new GggMoveSign( “ sign3 “ ); tmpObj3.Run(); /**/ /* * * javascript GggMoveSign 移动广告类 注意移动的轨迹可以根据自己的需要 修改 GetNextY GetNextX 方法 * signId 要移动的对象 * 2007-7-5 GGG mail:gggxin@zj.com QQ:632519 http://www.zggo.com */ function GggMoveSign(signId) … {
eval( “ this.mSignid= “ + signId); // 这样就充许传递字符窜为对象 this .mStepMove = 10 ; // 每次移动几个像素 this .mDelay = 100 ; // 每隔多少时间移动一次 this .mMoveable = true ; // 是否能移到的标记 this .mTimer; // 时钟 // 可以浮动的边界 this .mMaxX; this .mMaxY; this .mMinX; this .mMinY; // 当前对象的座标位置 this .mCurrX = 0 ; this .mCurrY = 0 ; // 移动的方向 this .mMoveDirectionX = 1 ; // 1 表示从左到右 增加 0 减少 this .mMoveDirectionY = 1 ; // 1 从上到向 // 设制能否移动状态 this .SetMoveable = function (isMoveable) … {
this .mMoveable = isMoveable; if (isMoveable) this .Run() else clearTimeout(this .mTimer) } // 得到当前要移动对像的宽 this .GetSignWidth = function () … {
return ( this .mSignid).offsetWidth; } // 当前要移动对像的高 this .GetSignHeight = function () … {
return ( this .mSignid).offsetHeight; } /**/ /* * * 移到指定位置 x y */ this .MoveTo = function (x,y) … {
// 保存当前座标 this .mCurrX = x; this .mCurrY = y; ( this .mSignid).style.left = this .mCurrX + document.body.scrollLeft; ( this .mSignid).style.top = this .mCurrY + document.body.scrollTop; } /**/ /* * * 得到对像移动到下一个 X 座标 的位置 */ this .GetNextX = function () … {
// 当前对像所在位置 var curr_pos = this .mCurrX; // 移动后如果超出最大宽度 弹回 返回 if ( this .mMoveDirectionX == 1 ) … {
curr_pos += this .mStepMove; } else curr_pos -= this .mStepMove; // 移动后如果超出最大宽度 弹回 返回 if (curr_pos > this .mMaxX ) // 碰到右边界 弹回 … {
this .mMoveDirectionX = 0 ; } else if (curr_pos < this .mMinX ) // 碰到左边界 弹回 this .mMoveDirectionX = 1 ; return curr_pos; } /**/ /* * * 得到对像移动到下一个 y 座标 的位置 */ this .GetNextY = function () … {
// 当前对像所在位置 var curr_pos = this .mCurrY ; if ( this .mMoveDirectionY == 1 ) … {
curr_pos += this .mStepMove; } else curr_pos -= this .mStepMove; // 移动后如果超出最大宽度 弹回 返回 if (curr_pos > this .mMaxY) // 碰到下边界 弹回 … {
this .mMoveDirectionY = 0 ; } else if (curr_pos < this .mMinY) // 碰到上边界 弹回 this .mMoveDirectionY = 1 ; return curr_pos; } /**/ /* * * 自动移动 */ this .Move = function () … {
if ( this .mMoveable) this .MoveTo( this .GetNextX(), this .GetNextY()); } /**/ /* * * timeDelay 每隔多少时间移动一次 * stepMove 每次移动几个像素 */ this .Run = function (timeDelay,stepMove) … {
var obj_name = this ; if (timeDelay) this .mDelay = timeDelay; if (stepMove) this .mStepMove = stepMove; with ( this .mSignid) … {
style.position = “ absolute “ ; // 设定为绝对定位 visibility = “ visible “ ; onmouseover = function () … {obj_name.SetMoveable( false )} ; // 鼠标经过,停止滚动 onmouseout = function () … {obj_name.SetMoveable( true ) } ; // 鼠标离开,开始滚动 } // 设定边界 this .mMaxX = document.body.clientWidth – this .GetSignWidth() – 10 ; this .mMaxY = document.body.clientHeight – this .GetSignHeight() – 10 ; this .mMinX = 10 ; this .mMinY = 10 ; this .mTimer = setInterval( function () … {obj_name.Move();} , this .mDelay); // 开启定时器 } }
</
script
>
</
BODY
>
</
HTML
>
下载http://dl2.csdn.net/down4/20070705/05131644390.html http://dl2.csdn.net/down4/20070705/05131720132.js
如果 document.body.scrollTop 不起作用 请用 document.documentElement.scrollTop 来代替
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/191403.html 原文链接:https://javaforall.net