您的位置:首页 > 其它

浮动广告-兼容ie6,ie7,firefox2,3

2013-04-09 16:31 405 查看

浮动广告-兼容ie6,ie7,firefox2,3

<!--浮动客服开始-->

<script type="text/javascript">

<!--

function Float(id, initX, initY, align){

this.startX = (initX)? initX : 0;//冒号后为默认横向位置,相对值,如对齐方式为右,则从最右端开始计算

this.startY = (initY)? initY: document.documentElement.scrollTop + document.documentElement.clientHeight-160;//同上,默认纵向位置,页面低端-160px,如客服信息较多显示不完整,请尝试加大最后一个数字

this.align = (align)? align: "right";//同上,对齐方式,默认右对齐,则横向位置从屏幕最右端算起

this.x = this.startX;

this.y = this.startY;

//var isNs = (navigator.appName.indexOf("Netscape") != -1);

this.div = document.getElementById(id);

this.init = function() {

this.div.style.top = this.startY + "px";

if(this.align == "left")

this.div.style.left = this.startX + "px" ;

else

this.div.style.right = this.startX + "px" ;

}

this.refresh = function(){

this.y += (getRoot().scrollTop + this.startY - this.y)/8;

this.div.style.top = this.y + "px" ;

}

this.floating = function(objName){

setInterval(objName+'.refresh()', 10);

}

this.init();

}

function getRoot(){

if(document.documentElement && document.body){

return (document.documentElement.scrollTop > document.body.scrollTop) ? document.documentElement : document.body;

}else if(document.documentElement){

return document.documentElement;

}else{

return document.body;

}

}

//-->下方第一个层为定位层,width可调整层宽度,第二个之后层样式默认为ecshop模板右边导航栏样式,可自行调整,如需大面积更换,请保留第一个层标签定位,替换其余html内容,默认采用ul标签排列各元素

</script>

<div id="divStayTopright" style="position:absolute; width:150px;">

这里放你需要的内容

</div>

<script type="text/javascript">

//此处创建浮动窗口实例,函数原型为float(对象id,横向位置,纵向位置,对齐方式),其中位置为数字,对齐方式为left或right,如需两个浮动客服窗口,可用不同参数创建两个实例

var o1 = new Float("divStayTopright");

o1.floating('o1');

</script>

<!--浮动客服结束-->
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: