Hi,

I'm using DMW MX2004 to create a website for my organization. Just recently the cross-browser issue came to me. I tested the page with the newly installed Firefox and it didn't appear the way it's supposed to.

Below is the code for centering the <div> on the page. It works just fine with IE, but not with Firefox. I heard Firefox incorporated document.all last year. It shouldn't be the case (or so I thought).

Could anyone see why it doesn't work with Firefox?

Thanks for any advice!


-----------------------


function BW_centerLayers() {
if (document.layers || document.all || document.getElementById){
var winWidth, winHeight, i, horz, vert, width, height, offsetX, offsetY, negX, negY, group, x, y, args;

args = BW_centerLayers.arguments;

onresize = BW_reload;

winWidth = (document.all)?document.body.clientWidth:window.innerWidth;
winHeight = (document.all)?document.body.clientHeight:window.innerHeight;

for (i=0; i<(args.length-9); i+=10) {
horz = args[i+1];
vert = args[i+2];
width = parseInt(args[i+3]);
height = parseInt(args[i+4]);
offsetX = parseInt(args[i+5]);
offsetY = parseInt(args[i+6]);
negX = args[i+7];
negY = args[i+8];

x = ((winWidth - width)/2) + offsetX;
y = ((winHeight - height)/2) + offsetY;

x = (negX=='false' && (x < 0))?0:x;
y = (negY=='false' && (y < 0))?0:y;

layerObj = (document.getElementById)?document.getElementById(args):MM_findObj(args);

if (layerObj!=null) {
layerObj = (layerObj.style)?layerObj.style:layerObj;
layerObj.left = (horz=="true")?x:layerObj.left;
layerObj.top = (vert=="true")?y:layerObj.top;
}
}
}
}

By breaking it down to individual steps, you'll be able to find exactly which line is failing. That's how you need to approach code troubleshooting--one step at a time.

Just looking at your code, I don't notice obvious issues, although I don't know what the parseInt() user-defined function does. It will be important that BW_centerLayers() does not get called until after the body has rendered for it to work in IE.

If you have a page I can go to to test, I can look at in IE and FF to help you.

Although I do understand C (and therefore javascript), I don't have a good base on either DOM or CSS. I learn them only when I am forced to. The code above was generated by DMW, which unfortunately favors IE rendering method.

I just made a workaround for the problem with Firefox so that the page won't look messy on it. But it'd be nice if both browsers could display the page in the same pattern.

Here is the page:

http://www.geocities.com/tskxmeaw

It won't be up until tomorrow due to download limit.

Thanks, Troy!

This article has been dead for over six months. Start a new discussion instead.