Setting <div> margin for NN4

I

Ian Rastall

This really is a JavaScript question. I have a site that looks fine in
everything but NN4. I'm afraid I don't have a URL, because the site is
very much unfinished.

The site is a header (which is a table) and a main <div> underneath
that. The main <div> is set to have a top margin of 3%, which works
fine, except in NN4. There, it looks like it has a margin of 20%, or
even larger.

I couldn't fix it with the @import hack, so I thought I might try
JavaScript. I tried something like this:

<script language="JavaScript" type="text/javascript">
if (document.layers) frank.styles.margin-top = "-20%"
</script>

(I called the <div> "frank" ...)

I'm very sorry, because I'm almost certain this isn't real JavaScript.
I'm just shooting in the dark. Is this *going* in the right direction,
or is this approach completely flawed? Would NN4 even understand
something like this?

TIA

Ian
 
D

Dom Leonard

Ian said:
The site is a header (which is a table) and a main <div> underneath
that. The main <div> is set to have a top margin of 3%, which works
fine, except in NN4. There, it looks like it has a margin of 20%, or
even larger.

I couldn't fix it with the @import hack, so I thought I might try
JavaScript. I tried something like this:

<script language="JavaScript" type="text/javascript">
if (document.layers) frank.styles.margin-top = "-20%"
AFAIK you can only access a DIV element through javascript in NS4 if it
is positioned. If it *is* positioned, then
if(document.layers)
document.layers['frank'].style.marginTop=....;
might get you access to the style object property of the layer and set
its top margin. At the same time, a positioned element might better
placed using top and left properties than margin. [Note javascript style
properties use interCaps spelling to replace CSS hyphenated names.]

<snip>

Would NN4 even understand
something like this?

Probably not. NS4 used CSS positioning before it became standardised,
and has multiple errors and inconsistencies with standard CSS.

To understand what NS4 *might* be doing with your percentage values,
take a Header element like
<h1 style="font-size:200%">Hello</h1>
The percentage size is calculated on the default font-size of H1 and not
the containing body (resulting in a font size of 400% for the H1
element.) This taking base percentage from the wrong place and generally
getting inheritance wrong or losing track of it is a big feature of NS4.
Even with care, absolute measurements (px or pt) may be required for NS4.

The other alternative is to put *all* CSS in the stylesheet, and use
@media rules to make sure *none* of it is visible to NS4, which can then
render using its default style sheet and present like a version 3 browser.

Dom
 
I

Ian Rastall

AFAIK you can only access a DIV element through javascript in NS4 if it
is positioned.

Thanks, Dom. I might give relative positioning a shot, although I'll
never mess with absolute positioning again. The last thing I want is
to mess up the site on every other browser. It isn't like NS4 is being
used that much anymore.

It's the allure of desktop-publishing-style consistency. I have that
with every other browser I've tested.

Thanks again,

Ian
 
I

Ian Rastall

Thanks, Dom. I might give relative positioning a shot

Sorry to respond to my own post ... and man, I hate to post this on a
JavaScript ng, but I found a solution (in CSS). This is a hack I ran
across on a Google search. If you were to type:

div.text {/;margin-top: 3%;}

every browser would understand this *except* for NS4. So there you go.
I now return you to a JavaScript discussion. <grin>

Ian
 
I

Ian Rastall

Thus if you have a div that is not positioned no script in NN4 is able
to change any style of it.
Even if the div were positioned you could only change the visibility and
the clipping but not margins.

Thanks, Martin.

Ian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top