clientWidth issues in IE7!! Noob needs help with small script.

Discussion in 'JavaScript' started by head in a pan, Mar 21, 2007.

  1. #1
    Hello - yes, I am new. I am scared. Help me!

    Trying something really basic - got it working fine in other browsers but ie7 is not allowing it.

    I have a floating/persistent layer - yes, I know they can be horrible - but it's what I require just this once.

    It is meant to sit at the bottom left of the screen, no matter where you scroll.

    It works going up & down (clientHeight) but will NOT move away from the left side of the screen when you scroll horizontally.

    As I said - works fine in mozilla etc but NOT in ie7.

    Please help me - I have tried so many things and no joy. :confused:

    
    <!--Here is where Part the XY Script starts-->
    <div id="divBottomLeft"  style="position:absolute">
    
    <!--        My layer content          -->
    
    
    
    
    </div>
    
    <!--Below is the floating layer script-->
    
    <script type="text/javascript">
    var ns = (navigator.appName.indexOf("Netscape") != -1);
    var d = document;
    var px = document.layers ? "" : "px";
    function JSFX_FloatDiv(id, sx, sy)
    {
    	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
    	window[id + "_obj"] = el;
    	if(d.layers)el.style=el;
    	el.cx = el.sx = sx;el.cy = el.sy = sy;
    	el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px; this.style.right=y+px; this.style.bottom=y+px;};
    	el.flt=function()
    	{
    		var pX, pY;
    		pX = ns ? pageXOffset : document.documentElement && document.documentElement.scrollLeft ? 
    		document.documentElement.scrollLeft : document.body.scrollLeft;
    		if(this.sx<0) 
    		pX += ns ? clientWidth : document.documentElement && document.documentElement.clientWidth ? 
    		document.documentElement.clientWidth : document.body.clientWidth;
    		
    		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
    		document.documentElement.scrollTop : document.body.scrollTop;
    		if(this.sy<0) 
    		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
    		document.documentElement.clientHeight : document.body.clientHeight;
    		this.cx += (pX + this.sx - this.cx)/8;
    		this.cy += (pY + this.sy - this.cy)/8;
    		this.sP(this.cx, this.cy);
    		setTimeout(this.id + "_obj.flt()", 40);
    	}
    	return el;
    }
    
    JSFX_FloatDiv("divBottomLeft",    5, -40).flt();
    
    
    </script>
    
    Code (markup):
     
    head in a pan, Mar 21, 2007 IP