PDA

View Full Version : ignore browses


alaios
08-30-2002, 02:12 PM
I want the code to detect the current version of a browser.
If the user has the Netsape browser lower version from 6 and Ie lower from 5 .I want to send all these in other page. And if it has any other browser also to change the url....
Can u help me?

Vladdy
08-30-2002, 02:25 PM
Here is the code that will identify the IE versions 5+, NS versions 6+ and Mozilla. However if your goal is to identify DOM compliant browsers, some would suggest using
if(document.getElementById)

var browser = '';
var version = 0.0;
var str = ''

switch(navigator.appName)
{ case 'Microsoft Internet Explorer':
browser='ie';
str = navigator.appVersion;
str = str.substring(str.indexOf('MSIE')+4,str.length);
version = parseFloat(str);
break;
case 'Netscape':
if(navigator.vendorSub!='')
{ browser='ns';
version=parseFloat(navigator.vendorSub);
}
else
{ browser='mz'
version=parseFloat(navigator.appVersion);
}
break;
default:
browser='unknown';
break;
}

jkd
08-30-2002, 03:58 PM
Originally posted by Vladdy
However if your goal is to identify DOM compliant browsers, some would suggest using
if(document.getElementById)

Which is still the incorrect way for DOM support:

document.implementation.hasFeature('Feature','Version')

returns a boolean on whether it has the feature or not:

document.implementation.hasFeature('HTML', '1.0')

Says whether or not the browser supports DOM1 HTML.

document.implementation.hasFeature('XPath', '3.0')

Says the browser supports the DOM3 Xpath module - currently only true in NS7 and recent Mozilla builds.

Vladdy
08-30-2002, 04:03 PM
Originally posted by jkd


Which is still the incorrect way for DOM support:



- which I completely agree with.. ;) ;)

brothercake
08-30-2002, 04:10 PM
Originally posted by jkd
document.implementation.hasFeature('Feature','Version')

returns a boolean on whether it has the feature or not:



The trouble with hasFeature is that it only returns a boolean - what if the browser has partial support for, say DOM 1 HTML? a false return would imply no support at all, where a true return would imply total support.

I read something recently that was talking about this, and the guy who was writing it suggested that perhaps hasFeature should not be a boolean return., for precisely this reason.

jkd
08-30-2002, 04:40 PM
Yeah, that is a problem I've noticed.

document.implementation.hasFeature('CSS', '2.0')

returns true in Mozilla. While it has excellent support for the DOM2 CSS interface, it is missing the entire DocumentCSS.getOverrideStyle method, and a few trivial things here and there.

document.implementation.hasFeature('Traversal', '2.0') returns false in Mozilla, despite it supporting over 50% of the specs - TreeWalker and NodeFilter, but not NodeIterator. Sometimes all you need is just the TreeWalker and NodeFilter interfaces.

But I still think it is generally better to check for DOM1 support through hasFeature (forget about checking for DOM2 and DOM3 interfaces for now though, only Mozilla supports them anyway), then by checking for getElementById - which implies nothing about other DOM1 methods.

brothercake
08-30-2002, 05:48 PM
Yeah it probably is - certainly more "future scaleable" to do it that way.

It's opera 7 that's forcing me to change my thinking about detection techniques - i've always relied on a combination of userAgent and object detection, but that's becoming increasingly convoluted, and will be more so once window.opera is no longer a singularly useful object.

joh6nn
08-31-2002, 01:13 AM
i look forward to the day when browser detection will be such a distant memory, that i'll actually be able to laugh about it. and then punch bill gates.

whammy
09-01-2002, 03:33 AM
Let me know when you're there... I want to take a whack a the netscape guys too... lol.

How hard could it be to limit the text in a textarea programatically? They still haven't figured it out in 6.2 and now I hear that netscape has come out with a 7.0 browser. LOL.

I bet they still have really basic stuff wrong with it like they have always had. I'm going to download it just to find out. Last time I tried (NS 6.2) you couldn't make a textarea wrap no matter what. Considering that was one of the earliest mistakes they made with 3.x and 4.x browsers, you'd think they would have covered it... *sigh*

What kills me is if they can't even get basic functionality working like that, how do you expect these guys to make anything work right?

jkd
09-01-2002, 04:23 AM
Originally posted by whammy
Last time I tried (NS 6.2) you couldn't make a textarea wrap no matter what. Considering that was one of the earliest mistakes they made with 3.x and 4.x browsers, you'd think they would have covered it... *sigh*

Umm, this text I am typing right now is wrapping in the textarea.

Auto-wrapping can be a hindrance too you know - like when I'm writing code in a textarea. Simply because *you* don't like doesn't mean it is a bad browser. As a matter of fact, Mozilla is a clearly superior browser when you look at what it can do, how well it can do it, how easily you can write it, and then compare it to IE.

How can you judge your entire opinion of the browser on just that one issue?
If you ask me, it is IE that can't get anything right. I consider decent DOM and CSS support "basic" functionality now that everything supports HTML4 satisfactorily. IE completely fails in that regard. DOM1 and poor CSS2 does not cut it.

hypedup.co.uk
09-01-2002, 08:31 AM
Originally posted by whammy
Last time I tried (NS 6.2) you couldn't make a textarea wrap no matter what.

i noticed this annoying problem too, but i found out how to cure it. if row="X" is added to the input tag, it will then wrap. so if you are setting the size of the textarea using style="width:100px;height:30px" then it doesnt matter what the X in row is, as it still sizes the textarea from what you put in the style tag. but for some reason, it will now wrap the text perfectly!

paul @ www.hypedup.co.uk

whammy
09-01-2002, 09:00 PM
I'm not judging the browser by only that (there were lots of things I didn't like about NS 6.x); nor am I defending IE in any way ;)

Just one example of something that was annoying to me. :D