用js完成悬浮广告的完整版
来源:互联网 发布:淘宝发货时间怎么看 编辑:程序博客网 时间:2024/05/29 15:15
原理就不多说了,跟上篇是一样的,这是这个又加了一个方向而已,下面是代码供大家参考
<!DOCTYPE html><HTML><head> <meta charset="utf-8"> <style> #mv{width:200px; height:200px; background-color:pink; position:absolute } </style> <script> var obj=null; var x =10; var y =10; var changeheight=true; var changewidth =true; function init(){ obj=document.getElementById("mv"); alert(parseInt(obj.style.top)); setInterval(move,100); } function move(){ var height = document.documentElement.clientHeight-obj.offsetHeight; var width = document.documentElement.clientWidth-obj.offsetWidth; if(changeheight && changewidth){ //长和高都增加的时候 if(x>=width){ changewidth=false; }else if(y>=height){ changeheight=false; }else{ x+=14;y+=10; obj.style.left=x+"px"; obj.style.top=y+"px"; } }else if (changeheight && !changewidth){ //长减少高增加 if(x<=10){ changewidth=true; }else if(y>=height){ changeheight=false; }else{ x-=14;y+=10; obj.style.left=x+"px"; obj.style.top=y+"px"; } }else if(!changeheight && changewidth){ //长增加高减少 if(x>=width){ changewidth=false; }else if(y<10){ changeheight=true; }else{ x+=14;y-=10; obj.style.left=x+"px"; obj.style.top=y+"px"; } }else{ //长和高都减少 if(x<10){ changewidth=true; }else if(y<10){ changeheight=true; }else{ x-=14;y-=10; obj.style.left=x+"px"; obj.style.top=y+"px"; } } } </script></head><body onload="init()"><div id="mv" style="top:10px"></div></body></HTML>
0 0
- 用js完成悬浮广告的完整版
- 悬浮的广告是怎么用js设计出来的
- js悬浮广告效果
- Js悬浮广告效果
- js 悬浮广告
- JS右下角悬浮广告代码
- 常见的悬浮广告
- 福利啦,javaweb悬浮广告的js代码
- Js右下角悬浮广告效果代码
- JS+CSS 实现 悬浮滚动广告
- WebView与JS的那些事: 注入JS去除悬浮广告
- 悬浮广告
- 悬浮广告
- 悬浮广告&漂浮广告
- js的悬浮效果
- 【JS】网页悬浮广告及联系QQ客服侧边栏
- 运用js更改图片的classname来改变悬浮状态,鼠标悬浮用js改变边框
- 利用Service完成桌面的悬浮窗口
- NavigationController与TabBarController同时存在时self.tabBarItem.title = @"xxx"设置失效以及‘ selectedImage’
- 24:文件的简单读写(四)
- OC学习笔记四-OC11-@class关键字
- C++第八节:子类的三大件
- hdoj 5008 后缀数组+RMQ+二分
- 用js完成悬浮广告的完整版
- cin与scanf的区别
- [IOS]今天开始学UI---UIImageView
- android如何获取以太网mac地址
- OgnlContext源码分析
- 对apk进行zipalign
- 【LIS 问题与 LCS 问题可以互相转换】
- UIScrollView, UIPageControl,UITableView
- POJ 2136 Vertical Histogram 水