PDA

View Full Version : Works in IE6, not in Netscape


bvoegele
01-25-2005, 04:28 AM
I've found a script out there to do what I want, which is to position a picture in the upper right corner of the window. The script works well in IE6, but I'm having troubles getting it to work in Netscape. I've followed the variables all the way through in Netscape, and they're correct into the checkLocation function. However, I don't get anything out of the evalMove function. What am I overlooking? All I can guess is that document.dynloadarea.left/top aren't valid (dynloadarea is a DIV id)

I'm new to this, so I'm sure it's something easy, but I don't see it.

Thanks for your help.......Brett


Piece of the code:

function setVariables() {
imgwidth=300; // logo width, in pixels
imgheight=400; // logo height, in pixels
if (navigator.appName == "Netscape") {
horz=".left";
vert=".top";
docStyle="document.";
styleDoc="";
innerW="window.innerWidth";
innerH="window.innerHeight";
offsetX="window.pageXOffset";
offsetY="window.pageYOffset";
}
else {
horz=".pixelLeft";
vert=".pixelTop";
docStyle="";
styleDoc=".style";
innerW="document.body.clientWidth";
innerH="document.body.clientHeight";
offsetX="document.body.scrollLeft";
offsetY="document.body.scrollTop";
}
}
function checkLocation() {
objectXY="dynloadarea";
var availableX=eval(innerW);
var availableY=eval(innerH);
var currentX=eval(offsetX);
var currentY=eval(offsetY);
x=availableX-(imgwidth+20)+currentX;
y=currentY+10;
evalMove();
setTimeout("checkLocation()",10);
}
function evalMove() {
eval(docStyle + objectXY + styleDoc + horz + "=" + x);
eval(docStyle + objectXY + styleDoc + vert + "=" + y);
}

bvoegele
01-25-2005, 04:43 AM
Also, if someone can tell me why when I post a new thread the icon is always a sealed envelope rather than the icon for a new post, I'd appreciate it. My posts seem to be the only ones with that icon, and it isn't described at the bottom of the page.

Brett

ElectricSheep
01-25-2005, 02:53 PM
I would think StyleSheets is a better way of accomplishing this if I have understood what you are after but the following code should work in IE, Netscape, Firefox, Opera etc

function setVariables() {
imgwidth=300; // logo width, in pixels
imgheight=400; // logo height, in pixels

// detect for a specific property - navigator properties are easily spoofed
if (window.innerWidth) {
innerW="window.innerWidth";
innerH="window.innerHeight";
offsetX="window.pageXOffset";
offsetY="window.pageYOffset";
}
// other browsers will fall through - it doesn't mean they support the else portion
else {
innerW="document.body.clientWidth";
innerH="document.body.clientHeight";
offsetX="document.body.scrollLeft";
offsetY="document.body.scrollTop";
}
}
function checkLocation() {
objectXY="dynloadarea";
var availableX=eval(innerW);
var availableY=eval(innerH);
var currentX=eval(offsetX);
var currentY=eval(offsetY);
x=availableX-(imgwidth+20)+currentX;
y=currentY+10;
evalMove();
setTimeout("checkLocation()",10);
}
function evalMove() {
//use W3C DOM
document.getElementById(objectXY).style.left=x;
document.getElementById(objectXY).style.top=y;
}