Results 1 to 2 of 2

Thread: scroll until div hits chrome

  1. #1
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default scroll until div hits chrome

    when you go to google news , take alook at the nav on the left.
    as you scroll down the page the left nav will move until the div hits the top of the chrome then it stays put while the rest of the page keeps scrolling
    how can you do this?

  2. #2
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    heres code for a persistant div, in this case its a navigational area that stays put even when you scroll but i cant seem to modify it like the google page
    anyone?

    Code:
    function fixedNav() {
    	var startX = 0, startY = 0;
    	var ns = (navigator.appName.indexOf("Netscape") != -1);
    	var d = document;
    	var px = document.layers ? "" : "px";
    	function ml(id) {
    		var el = d.getElementById ? d.getElementById(id) : d.all ? d.all[id] : d.layers[id];
    		if(d.layers) el.style=el;
    		el.sP = function(x,y) {
    			this.style.left=x+px;
    			this.style.top=y+px;
    			};
    		el.x = startX;
    		el.y = startY;
    		return el;
    	}
    	window.stayTopLeft=function() {
    		var pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
    		var dY = (pY > startY) ? pY : startY;
    		ftlObj.y += (dY - ftlObj.y)/8;
    		ftlObj.sP(ftlObj.x, ftlObj.y);
    		setTimeout("stayTopLeft()", 5);
    	}
    	ftlObj = ml("sidebar");
    	stayTopLeft();
    }

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •