Browser Detection - Mozilla 1.3+ & IE 5.5+

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

    Browser Detection - Mozilla 1.3+ & IE 5.5+

    Hello,

    htmlArea3 is a great script for those who want a free javascript WYSIWYG
    editor. The only problem is that it only works in Mozilla 1.3+ & IE 5.5+.

    I'd like to find some piece of javascript to not invoke the WYSYWYG if a
    browser that supports it isn't being used. To do that I need to know some
    very specific stuff about the browser, and the different browsers haven't
    made this very easy.

    The best I could come up with thus far is posted to their forum here:


    But there must be an easier way to do this.

    If someone has any suggestions of a script which would allow me to envoke
    the script only if a viable browser was being used I'd appreciate seeing
    it.

    Mike
  • kaeli

    #2
    Re: Browser Detection - Mozilla 1.3+ & IE 5.5+

    In article <pan.2003.10.17 .03.44.04.57214 3@openconcept.c a>,
    mike@openconcep t.ca enlightened us with...[color=blue]
    >
    > If someone has any suggestions of a script which would allow me to envoke
    > the script only if a viable browser was being used I'd appreciate seeing
    > it.
    >[/color]


    What objects does it use that only IE5.5 and Mozilla 1.3 have? Test for
    those.

    For example, if it uses document.getEle mentById, test for that.

    if (document.getEl ementById)
    {
    // invoke
    }
    else
    {
    alert("you aren't using the right browser.");
    }

    Best way to not get into trouble with browser detection is to detect for
    objects you use.

    -------------------------------------------------
    ~kaeli~
    Jesus saves, Allah protects, and Cthulhu
    thinks you'd make a nice sandwich.


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

    Comment

    • Mike Gifford

      #3
      Re: Browser Detection - Mozilla 1.3+ &amp; IE 5.5+

      Hi Kaeli,

      That's a good suggestion.. I just have to find out what those
      objects might be.

      Mike

      On Fri, 17 Oct 2003 07:33:04 +0000, kaeli wrote[color=blue]
      > What objects does it use that only IE5.5 and Mozilla 1.3 have? Test for
      > those.
      >
      > For example, if it uses document.getEle mentById, test for that.
      > if (document.getEl ementById)
      > {
      > // invoke
      > }
      > else
      > {
      > alert("you aren't using the right browser.");
      > }[/color]

      Comment

      • Martin Honnen

        #4
        Re: Browser Detection - Mozilla 1.3+ &amp; IE 5.5+



        Mike Gifford wrote:
        [color=blue]
        > Hello,
        >
        > htmlArea3 is a great script for those who want a free javascript WYSIWYG
        > editor. The only problem is that it only works in Mozilla 1.3+ & IE 5.5+.
        >
        > I'd like to find some piece of javascript to not invoke the WYSYWYG if a
        > browser that supports it isn't being used. To do that I need to know some
        > very specific stuff about the browser, and the different browsers haven't
        > made this very easy.
        >
        > The best I could come up with thus far is posted to their forum here:
        > http://www.interactivetools.com/ifor...r_Moz__P16141/
        >
        > But there must be an easier way to do this.
        >
        > If someone has any suggestions of a script which would allow me to envoke
        > the script only if a viable browser was being used I'd appreciate seeing
        > it.[/color]

        All that editing makes use of
        document.execCo mmand
        so you can check for that, and I think if you call
        document.execCo mmand('command' )
        on a command that is not supported then the return value indicates that
        respectively there is also
        document.queryC ommandEnabled
        to check support

        --

        Martin Honnen


        Comment

        • Mike Gifford

          #5
          Re: Browser Detection - Mozilla 1.3+ &amp; IE 5.5+

          Thanks Mark,

          On Fri, 17 Oct 2003 16:04:13 +0200, Martin Honnen wrote:[color=blue]
          > All that editing makes use of
          > document.execCo mmand
          > so you can check for that, and I think if you call
          > document.execCo mmand('command' )
          > on a command that is not supported then the return value indicates that
          > respectively there is also
          > document.queryC ommandEnabled
          > to check support[/color]

          Someone suggested the following, which worked fine for both IE & Mozilla:
          if((document.al l && document.design Mode) || (document.desig nMode)) {
          // Should work fine with htmlArea
          }

          May come back to execCommand if we run into any problems.

          Mike


          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: Browser Detection - Mozilla 1.3+ &amp; IE 5.5+

            Mike Gifford wrote:[color=blue]
            > Thanks Mark,[/color]
            ^^^^[color=blue]
            > On Fri, 17 Oct 2003 16:04:13 +0200, Martin Honnen wrote:[/color]
            ^^^^^^
            Hm?
            [color=blue][color=green]
            >> All that editing makes use of
            >> document.execCo mmand
            >> so you can check for that, [...][/color]
            >
            > Someone suggested the following, which worked fine for both IE & Mozilla:
            > if((document.al l && document.design Mode) || (document.desig nMode)) {
            > // Should work fine with htmlArea
            > }[/color]

            if (document.desig nMode)
            {
            ...
            }

            is equal and there is no point in paranthesing atoms.
            [color=blue]
            > May come back to execCommand if we run into any problems.[/color]

            You should always check for exactly the objects and properties you
            want to access. Anything else is not only bad style but will also
            most certainly create script errors. The proper way is:

            if (document.execC ommand)
            {
            ... document.execCo mmand(...) ...
            }

            See http://pointedears.de.vu/scripts/test/whatami pp. for details.


            PointedEars

            Comment

            Working...