div页面底部对齐[提取修改]

本文介绍了一段JavaScript代码,用于检测用户浏览器类型及版本,并根据浏览器窗口大小调整“实时信使”组件的位置。该脚本兼容IE、Firefox、Chrome、Opera和Safari等主流浏览器。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    <script language="javascript" type="text/javascript">
        function $()
        {
            return document.getElementById?document.getElementById(arguments[0]):eval(arguments[0]);
        }
        var Sys = {};
        var ua = navigator.userAgent.toLowerCase();
        if (window.ActiveXObject)
            Sys.ie = ua.match(/msie ([\d.]+)/)[1]
        else if (document.getBoxObjectFor)
            Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1]
        else if (window.MessageEvent && !document.getBoxObjectFor)
            Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1]
        else if (window.opera)
            Sys.opera = ua.match(/opera.([\d.]+)/)[1]
        else if (window.openDatabase)
            Sys.safari = ua.match(/version\/([\d.]+)/)[1];
    
        function getClientBounds()
        {
            var clientWidth;
            var clientHeight;
           
            if (Sys.ie)
            {
                clientWidth = document.body.clientWidth;
                clientHeight = document.body.clientHeight;
            }
            else if (Sys.safari)
            {
                clientWidth = window.innerWidth;
                clientHeight = window.innerHeight;
            }
            else if (Sys.opera )
            {
                clientWidth = Math.min(window.innerWidth, document.body.clientWidth);
                clientHeight = Math.min(window.innerHeight, document.body.clientHeight);
            }
            else
            {
                clientWidth = Math.min(window.innerWidth, document.documentElement.clientWidth);
                clientHeight = Math.min(window.innerHeight, document.documentElement.clientHeight);
            }
 
            return { width : clientWidth, height : clientHeight };
        }
 
        function resetLiveMessengerPosition()
        {
            var clientBounds = getClientBounds();
            var container = document.getElementById("liveMessengerContainer");
           
            var scrollLeft = (document.documentElement.scrollLeft ?
                    document.documentElement.scrollLeft : document.body.scrollLeft);
            var scrollTop = (document.documentElement.scrollTop ?
                    document.documentElement.scrollTop : document.body.scrollTop);
                   
            var containerLeft = scrollLeft + clientBounds.width - container.clientWidth - 5;
            var containerTop = scrollTop + clientBounds.height - container.clientHeight;
                   
            $("liveMessengerContainer").style.top=containerTop + "px";
            $("liveMessengerContainer").style.left=containerLeft + "px";
        }
       
        window.onscroll=function(){resetLiveMessengerPosition();};
        window.onresize=function(){ resetLiveMessengerPosition();};
        window.onload=function(){ resetLiveMessengerPosition();};
    </script>

转载于:https://www.cnblogs.com/olartan/archive/2009/02/10/1387420.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值