You are here: Re: Simple code for If Firefox Do this Else Do That « HTML « IT news, forums, messages
Re: Simple code for If Firefox Do this Else Do That

Posted by John Hosking on 07/29/07 17:52

mjones wrote:
> On Jun 30, 4:58 am, Ben C <spams...@spam.eggs> wrote:
>> On 2007-06-30, mjones <mich...@quality-computing.com> wrote:
>>
>>> 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.

>
> 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
<![endif]-->

> 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.


--
John
Pondering the value of the UIP: http://blinkynet.net/comp/uip5.html

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация