Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Problems with DOTD and Javascript

    hi guys, got a bit of a problem, i have a store scipt that utilizes a div that scrolls down the page with you, the problem is if i dont use this:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    Then the box will not move with the page, this was an ok hack for a short time, but my new page layout requires me to use this:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    otherwise the page wil be really screwy i really need some help here, heres the javascript source code:
    Code:
    function SetDiagramPosition() 
    {			
    	var xPos;
    	var yStart;
    	var yPos;
    	var yInc;
    	
    	if (IsNetScapeBrowser()) {
    	
    			xPos = window.pageXOffset + window.innerWidth - 145;
    
    			var yHeight = document.getElementById ("PriceBox_Layer").clientHeight;
    			if (yHeight == 0)
    				yHeight = 128;
    			yPos = window.pageYOffset + window.innerHeight - yHeight - 150;
    			
    				yStart = document.getElementById("PriceBox_Layer").style.top;			
    				yInc = Math.log(Math.pow(yPos - yStart, 3));
    				
    				if (yStart + yInc >= yPos)
    					yStart = yPos;
    				else if (yStart < yPos)	
    					yStart += yInc;
    				else
    					yStart = yPos;		
    
    			
    			document.getElementById("PriceBox_Layer").style.top = yStart;
    			document.getElementById("PriceBox_Layer").style.left = xPos;
    
    	}
    	else {
    
    			xPos = document.body.scrollLeft + window.document.body.clientWidth - 125;			
    			yPos = document.body.scrollTop + window.document.body.clientHeight - PriceBox_Layer.clientHeight - 150;
    			
    			
    				yStart = PriceBox_Layer.style.pixelTop;		
    				yInc = Math.log(Math.pow(yPos - yStart, 3));		
    				if (yStart + yInc >= yPos)
    					yStart = yPos;
    				else if (yStart < yPos)	
    					yStart += yInc;
    				else
    					yStart = yPos;		
    			
    			
    			PriceBox_Layer.style.pixelTop  = yStart;
    			PriceBox_Layer.style.pixelLeft = xPos;
    			
    
    	}
    	
    	var nTimeOut = 10;
    	setTimeout('SetDiagramPosition()', nTimeOut);
    
    }
    
    
    function IsNetScapeBrowser() 
    {
    	return !document.all;
    }

  • #2
    Senior Coder
    Join Date
    Feb 2006
    Location
    USA
    Posts
    1,013
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Your units are missing. The complete doctype puts the browser in Standards compliance mode, so it requires units.

    For example,
    Code:
    document.getElementById("PriceBox_Layer").style.top = yStart;
    document.getElementById("PriceBox_Layer").style.left = xPos;
    should be
    Code:
    document.getElementById("PriceBox_Layer").style.top = yStart+'px';
    document.getElementById("PriceBox_Layer").style.left = xPos+'px';
    P.S. That code is not very well written at all.
    Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions
    Java != JavaScript && JScript != JavaScript
    Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around.

  • #3
    New Coder
    Join Date
    May 2006
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmm still not working, heres the page: http://www.fasttracksites.com/servers.php just click on any of the customize buttons

    im not great with javascript, my biggest skills are in php

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Atlanta, GA.
    Posts
    313
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It doesn't work in IE.
    NS7 & FF are OK.
    Try using "documentElement" instead of "body"
    Code:
    xPos = document.documentElement.scrollLeft + document.documentElement.clientWidth - 125;		
    yPos = document.documentElement.scrollTop + document.documentElement.clientHeight - PriceBox_Layer.clientHeight - 150;
    For an explanation see here.
    The answer does not come from thinking outside the box, it comes from realizing the truth :-
    "There Is No Box". [JavaScript Gadgets'n'Gizmos][JavaScript-FX]

  • #5
    New Coder
    Join Date
    May 2006
    Posts
    62
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hey thanks a bunch Roy, shame that theres no one fix for all platforms an browsers

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Atlanta, GA.
    Posts
    313
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by spyke01
    hey thanks a bunch Roy, shame that theres no one fix for all platforms an browsers
    Maybe this might help. (and it works in any corner)
    The answer does not come from thinking outside the box, it comes from realizing the truth :-
    "There Is No Box". [JavaScript Gadgets'n'Gizmos][JavaScript-FX]


  •  

    Posting Permissions

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