...

View Full Version : Problems with DOTD and Javascript



spyke01
05-23-2006, 10:19 PM
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:


<!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:

<!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:


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;
}

Kravvitz
05-24-2006, 12:09 AM
Your units are missing. The complete doctype puts the browser in Standards compliance mode, so it requires units.

For example,

document.getElementById("PriceBox_Layer").style.top = yStart;
document.getElementById("PriceBox_Layer").style.left = xPos;
should be

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.

spyke01
05-24-2006, 03:43 PM
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

RoyW
05-24-2006, 10:53 PM
It doesn't work in IE.
NS7 & FF are OK.
Try using "documentElement" instead of "body"



xPos = document.documentElement.scrollLeft + document.documentElement.clientWidth - 125;
yPos = document.documentElement.scrollTop + document.documentElement.clientHeight - PriceBox_Layer.clientHeight - 150;


For an explanation see here. (http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html)

spyke01
05-24-2006, 11:25 PM
hey thanks a bunch Roy, shame that theres no one fix for all platforms an browsers

RoyW
05-25-2006, 05:24 AM
hey thanks a bunch Roy, shame that theres no one fix for all platforms an browsers
Maybe this might help. (http://www.javascript-fx.com/scriptclips/float/float_menu2.html) :) (and it works in any corner)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum