[原创]使用javascript制作漂浮的广告,在页面上自由飘转
2005-06-13 11:11
645 查看
floast.js原文件:
<!-- Begin
var xPos = 20;
var yPos = document.body.clientHeight;
var step = 1;
var delay = 30;
var height = 0;
var Hoffset = 0;
var Woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;
var interval;
dd.style.top = yPos;
function changePos() {
width = document.body.clientWidth;
height = document.body.clientHeight;
Hoffset = dd.offsetHeight;
Woffset = dd.offsetWidth;
dd.style.left = xPos + document.body.scrollLeft;
dd.style.top = yPos + document.body.scrollTop;
if (yon) {
yPos = yPos + step;
}
else {
yPos = yPos - step;
}
if (yPos < 0) {
yon = 1;
yPos = 0;
}
if (yPos >= (height - Hoffset)) {
yon = 0;
yPos = (height - Hoffset);
}
if (xon) {
xPos = xPos + step;
}
else {
xPos = xPos - step;
}
if (xPos < 0) {
xon = 1;
xPos = 0;
}
if (xPos >= (width - Woffset)) {
xon = 0;
xPos = (width - Woffset);
}
}
function start() {
dd.visibility = "visible";
interval = setInterval('changePos()', delay);
}
function pause_resume() {
if(pause) {
clearInterval(interval);
pause = false;
}
else {
interval = setInterval('changePos()',delay);
pause = true;
}
}
start();
// End -->
html文件调用方法:
<div id=dd style="Z-INDEX: 1; LEFT: 4px; WIDTH: 100px; POSITION: absolute; TOP: 372px; HEIGHT: 100px">
<p align="center">
<a href="contact/guize.html"><img src="images/play.gif" border="0" width="195" height="240"></a></p>
</div>
<script language="JavaScript" src="js/float.js"></script>
<!-- Begin
var xPos = 20;
var yPos = document.body.clientHeight;
var step = 1;
var delay = 30;
var height = 0;
var Hoffset = 0;
var Woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;
var interval;
dd.style.top = yPos;
function changePos() {
width = document.body.clientWidth;
height = document.body.clientHeight;
Hoffset = dd.offsetHeight;
Woffset = dd.offsetWidth;
dd.style.left = xPos + document.body.scrollLeft;
dd.style.top = yPos + document.body.scrollTop;
if (yon) {
yPos = yPos + step;
}
else {
yPos = yPos - step;
}
if (yPos < 0) {
yon = 1;
yPos = 0;
}
if (yPos >= (height - Hoffset)) {
yon = 0;
yPos = (height - Hoffset);
}
if (xon) {
xPos = xPos + step;
}
else {
xPos = xPos - step;
}
if (xPos < 0) {
xon = 1;
xPos = 0;
}
if (xPos >= (width - Woffset)) {
xon = 0;
xPos = (width - Woffset);
}
}
function start() {
dd.visibility = "visible";
interval = setInterval('changePos()', delay);
}
function pause_resume() {
if(pause) {
clearInterval(interval);
pause = false;
}
else {
interval = setInterval('changePos()',delay);
pause = true;
}
}
start();
// End -->
html文件调用方法:
<div id=dd style="Z-INDEX: 1; LEFT: 4px; WIDTH: 100px; POSITION: absolute; TOP: 372px; HEIGHT: 100px">
<p align="center">
<a href="contact/guize.html"><img src="images/play.gif" border="0" width="195" height="240"></a></p>
</div>
<script language="JavaScript" src="js/float.js"></script>
相关文章推荐
- android使用html+javascript来制作页面
- JavaScript小实例——制作页面定时弹出广告
- JavaScript学习——使用JS完成页面定时弹出广告
- android使用html+javascript来制作页面
- android使用html+javascript来制作页面
- [原创] 纯css漂浮广告页面垂直居中(兼容IE6、IE7、Firefox2.0)
- Android使用HTML和JavaScript制作页面
- 用javaScript制作漂浮广告
- js 漂浮广告代码(支持一个页面多次使用,其中一个带关闭功能哦!^^)
- 在Java EE 6中使用JSF 2.0简化页面制作
- 使用 原生js 制作插件 (javaScript音乐播放器)
- 使用jquery的load方法设计动态加载,并解决被加载页面JavaScript失效问题
- 使用JavaScript实现在页面中显示距离2017年中秋节的天数
- 有以下几种方法可以使用非阻塞方式下载 JavaScript,提快页面加载
- JavaScript中使用document.write向页面输出内容实例
- javascript页面上使用动态时间具体实现
- 使用javascript做页面间传值
- Javascript createElement和innerHTML增加页面元素的使用对比
- 页面右下角漂浮层上下或左右移动,广告浮动
- 使用JavaScript代码为博客园个人博客页面自动添置目录