您的位置:首页 > Web前端 > JavaScript

javascript 仿QQ/MSN右下角广告代码

2010-03-30 11:15 351 查看

<Script language="javascript">
<!--
window.onload = getMsg;
window.onresize = resizeDiv;
window.onerror = function(){};
//短信提示使用(asilas添加)
var divTop, divLeft, divWidth, divHeight, docHeight, docWidth, objTimer, i = 0;
/**
* 获取信息框和屏幕位置等参数, 并初始化信息框位置
*/
function getMsg()
{
try{
divTop = parseInt(document.getElementById("eMeng").style.top, 10);
divLeft = parseInt(document.getElementById("eMeng").style.left, 10);
divHeight = parseInt(document.getElementById("eMeng").offsetHeight, 10);
divWidth = parseInt(document.getElementById("eMeng").offsetWidth, 10);

docWidth = document.body.clientWidth;
docHeight = document.body.clientHeight;

document.getElementById("eMeng").style.top = parseInt(document.body.scrollTop, 10) + docHeight + 10;// divHeight
document.getElementById("eMeng").style.left = parseInt(document.body.scrollLeft, 10) + docWidth - divWidth;
document.getElementById("eMeng").style.visibility="visible";
objTimer = window.setInterval("moveDiv()", 10);
} catch(e) {
}
}

/**
* 用于设置判断信息框停留时间, 以及窗口大小或位置改变时信息框的位置设置
*/
function resizeDiv()
{
i += 1; // 用于保存计算信息框停留的时间
if (i > 1300) {
closeDiv(); // 客户想不用自动消失由用户来自己关闭所以屏蔽这句
}
try{ // 此代码仅当在窗口变化时可起作用, 而不使信息框消失等
divHeight = parseInt(document.getElementById("eMeng").offsetHeight, 10);
divWidth = parseInt(document.getElementById("eMeng").offsetWidth, 10);
docWidth = document.body.clientWidth;
docHeight = document.body.clientHeight;
document.getElementById("eMeng").style.top = docHeight - divHeight + parseInt(document.body.scrollTop, 10);
document.getElementById("eMeng").style.left = docWidth - divWidth + parseInt(document.body.scrollLeft, 10);
} catch(e) {
}
}

/**
* 控制窗口渐渐上升显示
*/
function moveDiv()
{
try {
if(parseInt(document.getElementById("eMeng").style.top, 10) <= (docHeight - divHeight +
parseInt(document
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: