Saturday, July 20, 2013

Who are you?

I develop and maintain web pages for our organization's internal use.  Some of our work uses an internally developed web framework, some of it is native HTML, and some of it uses Oracle's APEX framework.  All of it is delivered using Oracle 11g and Apache.

When we develop for internal use, we don't give much thought to the user's browser.  The browser must be a recent version of IE or Firefox, maybe Chrome, or maybe Safari.  And that's it.  No tablets.  No phones. No obsolete or obscure browsers.

Recently we took on a project developing pages for external use.  Now, I'm thinking about browsers.  What's out there? How many are there?  What HTML version do they support?  So, before I deliver content, the question is "who are you?"

Why do I care?  Well, new browsers support HTML5.  And if we properly develop and deliver HTML5, we should be safe with just about any current, commonly-used browser.  Floating divs are great advantage over table-based layouts.  Table-based layout is static; divs can float up to the next row if the browser is wide enough, or float under an element if the browser window is narrow.  And we don't need to worry whether it's a phone or narrow window on a desktop:  400px wide is 400px wide.

But, we do have some worries:  Older browsers.  Unusual browsers. Buggy browers.  In our internal environment, if a browser renders a page badly, we ask the user to use one of our approved browsers.  Delivering external content is another matter.  Users expect, rightly or wrongly, content to be delivered to them in a usable form.

So, there are two decisions to be made.  The business decision is whether to attempt to support any browser out there, or display a "Please upgrade to a modern browser" message.  The technical decision is identify to what browser we're delivering content and proceed based on the business decision.  It's the latter problem that interests me and that I'll address in this post.

We're running on an Oracle 11g database, so we'll use the OWA_UTIL package to help us identify the browsers.  OWA_UTIL has a couple of procedures that are useful to us.   The GET_CGI_ENV function will return the value of any variable in the CGI environment.  There are lots of variables in the CGI environment, and the PRINT_CGI_ENV procedure will print all them for us.   Visit the demo page and see who you are.

You're back!  That was a lot of strings.  So, how to interpret those browser strings?  There are several websites that provide lots of information.  UserAgentString.com has a description of the browser identication string for what must certainly be the entire universe of known browsers.  Also, www.zytrax.com/tech/web/browser_ids.html has a list of ids and tips on how to parse the id strings using regular expressions. 

No comments:

Post a Comment