Browser Detection - Mozilla 1.3+ & IE 5.5+

Discussion in 'Javascript' started by Mike Gifford, Oct 17, 2003.

  1. Mike Gifford

    Mike Gifford Guest

    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/ifo...e_F14/browser_detection_IE5.5_or_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.

    Mike
    Mike Gifford, Oct 17, 2003
    #1
    1. Advertising

  2. Mike Gifford

    kaeli Guest

    In article <>,
    enlightened us with...
    >
    > 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.
    >



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

    For example, if it uses document.getElementById, test for that.

    if (document.getElementById)
    {
    // 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.
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
    -------------------------------------------------
    kaeli, Oct 17, 2003
    #2
    1. Advertising

  3. Mike Gifford

    Mike Gifford Guest

    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
    > What objects does it use that only IE5.5 and Mozilla 1.3 have? Test for
    > those.
    >
    > For example, if it uses document.getElementById, test for that.
    > if (document.getElementById)
    > {
    > // invoke
    > }
    > else
    > {
    > alert("you aren't using the right browser.");
    > }
    Mike Gifford, Oct 17, 2003
    #3
  4. Mike Gifford wrote:

    > 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/ifo...e_F14/browser_detection_IE5.5_or_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.


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

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Oct 17, 2003
    #4
  5. Mike Gifford

    Mike Gifford Guest

    Thanks Mark,

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


    Someone suggested the following, which worked fine for both IE & Mozilla:
    if((document.all && document.designMode) || (document.designMode)) {
    // Should work fine with htmlArea
    }

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

    Mike
    Mike Gifford, Oct 17, 2003
    #5
  6. Mike Gifford wrote:
    > Thanks Mark,

    ^^^^
    > On Fri, 17 Oct 2003 16:04:13 +0200, Martin Honnen wrote:

    ^^^^^^
    Hm?

    >> All that editing makes use of
    >> document.execCommand
    >> so you can check for that, [...]

    >
    > Someone suggested the following, which worked fine for both IE & Mozilla:
    > if((document.all && document.designMode) || (document.designMode)) {
    > // Should work fine with htmlArea
    > }


    if (document.designMode)
    {
    ...
    }

    is equal and there is no point in paranthesing atoms.

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


    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.execCommand)
    {
    ... document.execCommand(...) ...
    }

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


    PointedEars
    Thomas 'PointedEars' Lahn, Oct 19, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phil Townsend

    browser detection for mobile devices

    Phil Townsend, Dec 2, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    724
    bruce barker
    Dec 2, 2004
  2. Carlos
    Replies:
    4
    Views:
    21,885
    amimpat
    Aug 11, 2009
  3. Henri
    Replies:
    9
    Views:
    1,816
    Toby Inkster
    Feb 22, 2005
  4. jaydev

    browser detection and redirection

    jaydev, Oct 23, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    435
    Mark Rae
    Oct 23, 2006
  5. jaydev
    Replies:
    41
    Views:
    1,428
    Chaddy2222
    Oct 27, 2006
Loading...

Share This Page