Want to create a wrapper for code that detects presence of IE or Netscape

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matthew

    Want to create a wrapper for code that detects presence of IE or Netscape

    Hello - I have this DHTML calendar that displays about 10 pixels off
    its target in Netscape 7.0 -- from the script layer I have the block
    of code identified that positions the calender on the screen. I was
    thinking if I could write a wrapper around this that would execute two
    different versions depending on which browser is coming in... for now
    I am only interested in all versions of IE and NS 7.0 (haven't tested
    it on earlier versions of NS, but would like to understand the flag
    adjustments). Thanks for anyone's help!! :)
  • kaeli

    #2
    Re: Want to create a wrapper for code that detects presence of IE or Netscape

    In article <199e3613.03120 40712.7cd36b7d@ posting.google. com>,
    mattsimc@yahoo. com enlightened us with...[color=blue]
    > Hello - I have this DHTML calendar that displays about 10 pixels off
    > its target in Netscape 7.0 -- from the script layer I have the block
    > of code identified that positions the calender on the screen. I was
    > thinking if I could write a wrapper around this that would execute two
    > different versions depending on which browser is coming in... for now
    > I am only interested in all versions of IE and NS 7.0 (haven't tested
    > it on earlier versions of NS, but would like to understand the flag
    > adjustments). Thanks for anyone's help!! :)
    >[/color]

    I've had similar problems with pixels. I stopped using them.

    As a workaround and only if only IE and NN7 are the only browsers, the
    following will work. (note: opera supports document.all)

    if (document.all)
    {
    // IE
    }
    else
    {
    NN
    }

    HTH

    --
    ~kaeli~
    I do whatever my Rice Krispies tell me to.



    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: Want to create a wrapper for code that detects presence of IEor Netscape

      kaeli <tiny_one@NOSPA M.comcast.net> writes:
      [color=blue]
      > As a workaround and only if only IE and NN7 are the only browsers, the
      > following will work. (note: opera supports document.all)[/color]

      Some versions of Opera. Some of them only sometimes. And so several
      other browsers too.
      [color=blue]
      > if (document.all)
      > {
      > // IE[/color]

      Bad idea. As you say, it works if the *only* browsers they will view
      the page are the *currently avilable* versions of IE and Mozilla.

      Most other current browsers, and potentially a lot of future browsers,
      will fail. So, don't go there, it's bound to come back and bite you in
      the posterior.

      The best way (IMNSHO[1]) is to
      1) Use a doctype that triggers standards mode. That will let IE 6 show
      the page according to the CSS 1 standard, instead of being bugwards
      compatible with the highly deprected IE 4. In most cases, IE 6 and
      Mozilla (and Opera and other standards supporting browsers) will then
      show the pages identically.

      I would use HTML 4.01 with en URL. Read more:
      <URL:http://msdn.microsoft. com/library/en-us/dnie60/html/cssenhancements .asp>
      <URL:http://mozilla.org/docs/web-developer/quirks/doctypes.html>
      <URL:http://www.opera.com/docs/specs/doctype/>

      2) Where the browsers still differ in rendering, make the page so that
      it looks correct in Mozilla. Then add the changes needed to make it
      look the same in IE, but wrap them in IE's conditional comments:
      <!--[if IE]> blah blah fixes IE blah <![end if]-->
      To all other browsers, it looks like a comment. To IE 5+, it is treated
      as normal content.

      <URL:http://msdn.microsoft. com/workshop/author/dhtml/overview/ccomment_ovw.as p>

      Normally, those two steps will be enough to fix any problems you might
      have with IE.

      /L
      [1] in my, not so humble, opinion.
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      • kaeli

        #4
        Re: Want to create a wrapper for code that detects presence of IE

        In article <d6b477ef.fsf@h otpop.com>, lrn@hotpop.com enlightened us
        with...[color=blue]
        >
        > 2) Where the browsers still differ in rendering, make the page so that
        > it looks correct in Mozilla. Then add the changes needed to make it
        > look the same in IE, but wrap them in IE's conditional comments:
        > <!--[if IE]> blah blah fixes IE blah <![end if]-->
        > To all other browsers, it looks like a comment. To IE 5+, it is treated
        > as normal content.
        >
        > <URL:http://msdn.microsoft. com/workshop/author/dhtml/overview/ccomment_ovw.as p>
        >[/color]

        That is SO cool. :)

        Thanks for sharing.

        --
        --
        ~kaeli~
        If a turtle doesn't have a shell, is he homeless or naked?



        Comment

        Working...