JavaScript floating window code in lower right corner

Source: Internet
Author: User

JavaScript floating window code in lower right corner
var winwidth = 0;
var winheight = 0;
var offsetbody=0;
function Finddimensions () {
if (window.innerwidth)
Winwidth = window.innerwidth;
else if ((document.body) && (document.body.clientWidth)
Winwidth = Document.body.clientWidth;
if (window.innerheight)
Winheight = Window.innerheight;
else if ((document.body) && (document.body.clientHeight)
Winheight = Document.body.clientHeight;
if (document.documentelement && document.documentElement.clientHeight && Document.documentElement.clientWidth) {
Winheight = Document.documentElement.clientHeight;
Winwidth = Document.documentElement.clientWidth;
}
Offsetbody=math.floor ((document.documentelement.clientwidth-document.body.clientwidth)/2)
}
Finddimensions ();
window.onresize=finddimensions;//when window adjustment is performed. Gets the height of the browser width.

var delta=0.25;
var collection;
var Closeb=false;
function Floaters (winheight) {
This.items = [];
This.additem = function (id,x,y,content) {
document.write (' <div id= ' + ID + ' style= ' z-index:10; position:absolute; Left: ' + (typeof (x) = = ' string '? Eval (x): x) + '; Top: ' + (typeof (y) = = ' string '? Eval (y): y) + ' > ' + content + ' ;/div> ');
var newitem = {};
Newitem.object = document.getElementById (ID);
newitem.x = x;
Newitem.y = y;
This.items[this.items.length] = NewItem;
}
This.play = function () {
collection = This.items;
SetInterval (' Play () ', 30);
}
}
function Play () {
if (winwidth<= 950 | | closeb) {
for (var i = 0;i < collection.length;i++) {
Collection[i].object.style.display = ' None ';
}
Return
}
for (var i = 0;i < collection.length;i++) {
var followobj = Collection[i].object;
var followobj_x = (typeof (collection[i].x) = = ' String ' eval (collection[i].x): collection[i].x);
var followobj_y = (typeof (collection[i].y) = = ' String ' eval (collection[i].y): COLLECTION[I].Y);

if (Followobj.offsetleft!= (Document.documentElement.scrollLeft + followobj_x-offsetbody)) {
var dx = (document.documentElement.scrollLeft + followobj_x-followobj.offsetleft-offsetbody) * DELTA;
DX = (dx > 0 1:-1) * Math.ceil (Math.Abs (DX));
FollowObj.style.left = (followobj.offsetleft + dx) + ' px ';
}
if (Followobj.offsettop!= (Document.documentElement.scrollTop + followobj_y)) {
var dy = (Document.documentElement.scrollTop + followobj_y-followobj.offsettop) * DELTA;
dy = (Dy > 0? 1:-1) * Math.ceil (Math.Abs (dy));
FollowObj.style.top = (followobj.offsettop + dy) + ' px ';

}
FollowObj.style.display = ';
}
}
function Closebanner () {
Closeb = true;
Return
}
var thefloaters = new Floaters (winheight);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.