Click to See Complete Forum and Search --> : Browser detection ie6


jimbob2812
10-09-2003, 07:06 AM
I am writting a sticky menu and so need to "sniff out" the browser. The browser I am currently testing on is ie6.0.

On surfing the web, I have gathered the way to implement the sticky menu is "document.documentElement.scrollTop" - at least for ie6.0...

It is suggested to use "if (document.documentElement && document.documentElement.scrollTop)" to determine if ie6.0 is being used, and if so to access the scrollTop property.

However, the detection part does not work. The scrollTop property is indeed what I need to use (proven by forcing the code to be executed) however all the pages say that the detection method should work, although it does not for me!

Please, does anyone have any ideas? One thought I had was it may be linked to DOCTYPE definition - I am currently using strict XHTML, although even when I remove the DTD, it still does not sniff out the scrollTop property correctly, even though the code still works...

Fang
10-09-2003, 08:23 AM
Use document.nodeType to seperate ie6 from earlier versions.
scrollTop can be used in ie5 (http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/scrolltop.asp)

jimbob2812
10-09-2003, 08:33 AM
It only goes and blooming works - FANTASTIC - and excuse my dodgy sense of humour, it's just because I have wasted hours on this...

Thanks a million...

James

gil davis
10-09-2003, 08:36 AM
The object scrollTop is an integer, and may contain zero, which would make the boolean compare equate to "false". You should find another way to tell if it exists.

You might want to use the "navigator" object to sniff for the browser.

jimbob2812
10-09-2003, 08:43 AM
Cheers Gil - that explains why my boolean compare was not working - I was stupidly assuming the property was not functioning as expected...