zoukankan      html  css  js  c++  java
  • jquery position fixed IE6 插件

    (function($) {
    jQuery.fn.PositionFixed = function(options) {
        var defaults = {
            x:0,            //left
            y:0,            //top
            isAll : false   //是否最大化  我后加的
        };
        var o = jQuery.extend(defaults, options);
        
        var isIe6=false//is ie ? yes:ie no: not ie
        if($.browser.msie && parseInt($.browser.version)==6)
            isIe6=true;            
        
        var html= $('html');
    if (isIe6 && html.css('backgroundAttachment') !== 'fixed') {
            html.css('backgroundAttachment','fixed') 
        };
        
        return this.each(function() {
        var domThis=$(this)[0];
        var objThis=$(this);
            if(isIe6)
            {
                
                 var left = parseInt(o.x) - html.scrollLeft(),
                     top = parseInt(o.y) - html.scrollTop();
                    objThis.css('position' , 'absolute');    
                    
                    domThis.style.setExpression('left', 'eval((document.documentElement).scrollLeft + ' + o.x + ') + "px"');
                    domThis.style.setExpression('top', 'eval((document.documentElement).scrollTop + ' + o.y + ') + "px"');
                    function _resize(){
                        var w = $(window),
                            ww = w.width(),
                            hh = w.height();
                        objThis.css({
                            width : ww,
                            height : hh    
                        });
                    }
                    if(o.isAll){
                        _resize();
                        $(window).bind({
                            "resize" : _resize,
                            "scroll" : _resize    
                        });
                    }
                    
            }
            else
            {
                objThis.css('position' , 'fixed').css('top',o.y).css('left',o.x);
            }
        
        });

    };


    })(jQuery)

    用法$(**).PositionFixed()

    参数说明见代码

     
     
  • 相关阅读:
    阶段一 第一周 2-5 2-6 构建maven聚合工程
    阶段一 第一周 2-3 前后端分离开发模式讲解
    阶段一 第一周 2-2前后端技术选型
    Linux基础
    SpringMVC复习
    电商航线整理
    Mybatis整理复习
    python re正则
    爬虫基础 简单正则
    mysql 备份 恢复 事物 ER模型 pymysql交互
  • 原文地址:https://www.cnblogs.com/sniper007/p/2376075.html
Copyright © 2011-2022 走看看