`
zhangshenqiu
  • 浏览: 9122 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
最近访客 更多访客>>
社区版块
存档分类
最新评论

浮动窗口

阅读更多

<div id="img" style="position:absolute; z-index=99;visibility: visible; left: 406px; top: 1060px; width: 198px; height: 128px;">
<a href="gsd.asp" onClick="MM_openBrWindow('#','wd','toolbar=yes,location=yes, status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=350,height=400')" target="_blank">
<img src="images/sky.gif" alt='img' width="128" height="128" border="0" onClick="pause_resume();" ></a>
</div>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var xPos = document.body.clientWidth-20;
var yPos = document.body.clientHeight/2;
var step = 1;
var delay = 5;
var height = 0;
var Hoffset = 0;
var Woffset = 0;
var yon = 0;
var xon = 0;
var pause = true;
var interval;
img.style.top = yPos;
function changePos() {
width = document.body.clientWidth;
height = document.body.clientHeight;
Hoffset = img.offsetHeight;
Woffset = img.offsetWidth;
img.style.left = xPos + document.body.scrollLeft;
img.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() {
img.visibility = "visible";
interval = setInterval('changePos()', delay);
}
function pause_resume() {
if(pause) {
clearInterval(interval);
pause = false;
}else {
interval = setInterval('changePos()',delay);
pause = true;
}
}
start();
// End -->
</script>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics