html全局浮窗,Html 实现浮动窗口
今天在寫一個html代碼時,需要用到浮動窗口,通知信息,網站找了一下,代碼如下
帶關閉按鈕的浮動窗口代碼(全屏漂浮)#fdck {border:1px solid #c0c0c0;margin:0 auto;padding:5px;background:#f0f0f0}
關閉
歡迎來到營了個銷!
http://www.hcsem.com/
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;
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.style.visibility = "visible";
interval = setInterval('changePos()', delay);
}
start();
博客地址來至:
http://www..com/huangcong/archive/2012/05/18/2507747.html
總結
以上是生活随笔為你收集整理的html全局浮窗,Html 实现浮动窗口的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Echart 5.0+版本报错Error
- 下一篇: Unity3D 性能优化