Forum Moderators: open

Message Too Old, No Replies

Browser detection help requested

navigator.appName and navigator.appVersion seem not to be enough...

         

albo

4:32 pm on Nov 22, 2005 (gmt 0)

10+ Year Member



My clickable thumbnails lead the client to a popup enlarged photo. The goal is a borderless
window, no scrollbars. Javascript uses navigator.appName (and I'm willing to use appVersion) to compute window.open screen size. This is easy, works beautifully in Firefox, IE, Opera; but Mozilla and Netscape yield unsightly scrollbars. I adjusted measurements for scrollbar: got unsightly borders bottom and right, so
I'll have to keep diddling. Meanwhile, navigator.appName yields "Netscape" for Firefox, Opera, Mozilla, and Netscape (and same "version" for appVersion no matter which "Mozilla" I'm running)! Anyone know of a better browser detection method?

rocknbil

7:34 pm on Nov 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Albo - you've cracked the first egg of why you should **not** use browser detection to perform your functions. Suppose you do get it all worked out, and next year Firefox begins returning "Firefox" instead of Netscape? And you've installed this on 20 sites? Or was it 30? It becomes a maintenance nightmare.

What you should do instead is try to detect the objects themselves independent of what browser it is. In this scenario, that equates to something that gives you the available screen area, who cares what browser it is. The simplest example is

if (screen.width) { .... do something }
else { .... do something default-ish }

albo

7:56 pm on Nov 22, 2005 (gmt 0)

10+ Year Member



Thanks for your example but...weird...for some reason I can see it on my smartphone but it doesn't display on my desktop. Would you be so kind as to sticky it to me?

albo

8:40 pm on Nov 22, 2005 (gmt 0)

10+ Year Member



And, to be more descriptive, the reason for browser detection is calculation with figuring of "chrome" (title bar, status bar, etc.) in window size, as you say, that could change moment to moment by pixel to pixel too. At least that is the algorithm I got from some ol' book.

Lynque

4:29 am on Nov 23, 2005 (gmt 0)

10+ Year Member



You could just strip out all of the DOM elements and give it one size regardless of the img size.

Don't know how this will look on a smart phone but browsers should have no problem with it.

if the user can't see it he/she won't use it he he ;-)

albo

3:28 pm on Nov 23, 2005 (gmt 0)

10+ Year Member



If my interpretation is correct, rocknbil's example seems provide centering on the existing window. I also need to be able
to be able to deduce/calculate styles for padding/margins for the
not-yet-created window. Now, in some cases, I get poor sizing/centering in some
browsers/OSs leading to either extra white-space or forced scrollbars. (It also differs
among the various "Mozilla"s.)...What I couldn't see on the desktop, BTW, was rocknbil's example code, not my img