Simple code for If Firefox Do this Else Do That

M

mjones

Hi All,

I know this can be done, but I'm not a programmer. I only know HTML
so I'm hoping there's a simple way to do this.

If it matters, I'm using HTML 4.01 Transitional and utf-8.

I need the code because FireFox and IE6 or 7 behave differently with
image tags and relative positioning.

I've got an iframe over an iframe and I need to force positioning due
to some nasty menu code that has a mind of its own. The menu has a
division style with z-index:999999, too. If anyone could explain what
that it, it might help me. I've read about it, but still can't seem to
get my head around it.

Thanks all,

Michele
 
J

Jonathan N. Little

mjones said:
Hi All,

I know this can be done, but I'm not a programmer. I only know HTML
so I'm hoping there's a simple way to do this.
URL?


If it matters, I'm using HTML 4.01 Transitional and utf-8.

New page...well that's your first mistake use HTML 4.01 strict for any
hope of consistency
I need the code because FireFox and IE6 or 7 behave differently with
image tags and relative positioning.

Think you have it backwards, most likely Firefox (et al.) are behaving
properly and IE is misbehaving. MS even provides a proprietary way to
handle IE deficiencies with conditional comments. You cannot do "if
Firefox to this else do that" but your can do "if IE do this else it
will be ignored be everyone else". But most likely it is not necessary
because it is probably do to some error in your markup. But how knows,
you did not supply a URL.
I've got an iframe over an iframe and I need to force positioning due
to some nasty menu code that has a mind of its own. The menu has a
division style with z-index:999999, too. If anyone could explain what
that it, it might help me. I've read about it, but still can't seem to
get my head around it.

Yep, I am sure there is a problem with your markup...
 
B

Ben C

Hi All,

I know this can be done, but I'm not a programmer. I only know HTML
so I'm hoping there's a simple way to do this.

If it matters, I'm using HTML 4.01 Transitional and utf-8.

I need the code because FireFox and IE6 or 7 behave differently with
image tags and relative positioning.

I've got an iframe over an iframe and I need to force positioning due
to some nasty menu code that has a mind of its own. The menu has a
division style with z-index:999999, too. If anyone could explain what
that it, it might help me. I've read about it, but still can't seem to
get my head around it.

Basically it means it gets displayed on top of anything with a lower
value of z-index, or auto z-index, that's also below the nearest thing
above it in the document tree that has non-auto z-index.

But often people don't realize that z-index only applies to positioned
elements, so they set it all over the place without it doing anything.

And 999999 is a silly number. Probably 9 would have been fine.
 
M

mjones

Basically it means it gets displayed on top of anything with a lower
value of z-index, or auto z-index, that's also below the nearest thing
above it in the document tree that has non-auto z-index.

But often people don't realize that z-index only applies to positioned
elements, so they set it all over the place without it doing anything.

And 999999 is a silly number. Probably 9 would have been fine.

For those looking for the answer, here's what worked:

In the head -

<script language="JavaScript" type="text/javascript">
var nav = window.navigator
var browserType=nav.appName.toUpperCase()
var browserVersion=nav.appVersion
var curr_fld
if (browserType.substring(0,3)=="NET")
{ browserType="Netscape"
} else

{ browserType="Microsoft"
}
</script>

In the body -

<script language="JavaScript" type="text/javascript">
if (browserType=="Microsoft") {
document.write("WHATEVER CODE YOU WANT IF FIREFOX")
}
else
{
document.write("WHATEVER CODE YOU WANT IF IE")
}
</script>

Hope that helps,

Michele
 
J

John Hosking

For those looking for the answer, here's what worked:

Nice of you to post back. Although...
In the head -

<script language="JavaScript" type="text/javascript">

Your "solution" will only possibly work if JS is turned on.
var nav = window.navigator
var browserType=nav.appName.toUpperCase()
var browserVersion=nav.appVersion
var curr_fld
if (browserType.substring(0,3)=="NET")
{ browserType="Netscape"

What does this have to do with Firefox?
} else

{ browserType="Microsoft"

Do not assume that the only other UA besides Netscape (or those
reporting the string "net" in their user-agent) is a Microsoft product.
}
</script>

In the body -

<script language="JavaScript" type="text/javascript">
if (browserType=="Microsoft") {
document.write("WHATEVER CODE YOU WANT IF FIREFOX")

Well, look, you've got it backwards.

All other things being equal, you're better off with:
<!--[if IE]>
whatever code for IE
said:
else
{
document.write("WHATEVER CODE YOU WANT IF IE")
}
</script>

The above doesn't really matter, though, because you seem to have missed
the point. Ben and Jonathan tried to point you in a better direction,
but browser sniffing is almost certainly the wrong way to go here. And
that's even if you do the sniffing right (and also assuming nobody's
cloaking or changing their browser's string).

A URL would have helped us help you, but I'm not sure there's enough
interest on any side for that to happen.
 
B

Beauregard T. Shagnasty

John said:
And that's even if you do the sniffing right (and also assuming
nobody's cloaking or changing their browser's string).

What would his code do with my UA string? :)

Borgzilla/31.0 (Starship Enterprise NCC-1701)
 

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

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top