Browser Detection - Mozilla 1.3+ & IE 5.5+

M

Mike Gifford

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
 
K

kaeli

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

Mike Gifford

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
 
M

Martin Honnen

Mike said:
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
 
M

Mike Gifford

Thanks Mark,

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
 
T

Thomas 'PointedEars' Lahn

Mike said:
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
 

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

No members online now.

Forum statistics

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

Latest Threads

Top