Gossamer Forum
Home : Products : DBMan : Installation :

Browser ID...

Quote Reply
Browser ID...
I found out, that Netscape can not handle 'gif' files in the background of a table, the input fields grab the bg. away. When I filled it with an ordinary color, it shows a good colored table. What I want is this:
How will I define a global var. as the used browser?? I think an -if-else statement will do for my backgrounds. So please give me a code for this:
If $browser='Netscape', $bground='bgcolor="#98FB98"'
elsif $browser='MIEXPLORER'
#bground='"background="http://url/to/bground.gif'", and call $bground where I will define the background(color).

Thanks in advance
Mart.
Quote Reply
Re: Browser ID... In reply to
Hi mart,

I'm curious as to where you got that from, or maybe I'm not understanding what you mean exactly. I use gifs as background images in my tables all the time, with no problems.

adam
Quote Reply
Re: Browser ID... In reply to
When a gif file is defined as background, in for example List All (Alle records) the screen behind the letters of the links is in Netscape white, in IExpl. it looks fine, so I had to made it a bgcolor. What I wanna know is if the script detects the name of the browser and how can I put that in a var. Also I like to have the code as defined above
Quote Reply
Re: Browser ID... In reply to
Mart, I don't know how to detect which browser the person is using. I believe there's something in Javascript, but I don't know for sure.

Adam, he's right. Netscape doesn't display a background image in a table. Not that I've been able to see anyway.



------------------
JPD





Quote Reply
Re: Browser ID... In reply to
Ah! I getcha now. I'm not sure how IE does it, because I try and avoid it wherever possible, but Netscape works like this. If you define a table with a background, it will accept it, but table rows and nested tables will also try and render the image. For instance, if you have a 400x400 table 1 cell by 1 cell and your BG is 400x400 it'll display it perfectly. But if you try and split the table into two rows, rather than displaying the complete image across the two rows, Netscape renders it in each row. The same thing happens in nested tables, it will try and render the parent's background image. And there are some problems with nested BG colours aswell. So while your bg is probably displaying, Netscape is playing buggery with it.

All of which is academic. And possibly wrong, but I think mart is wrong to some extent too, because otherwise Netscape Composer wouldn't have a background image option for tables (oooh, I love Netscape Composer!).

ANYWAY, you can access the users browser and OS data in Perl using the HTTP_USER_AGENT environment variable, like this:

$user_agent = $ENV{'HTTP_USER_AGENT'};

...which will give you something like this:

Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)

...which is probably pretty useless to you. So you'll have to tidy it and simplify it to make it easier to work with.

Alternatively, you could use JavaScript, which will simplify things a bit more, becuase you have more (and simpler) variables available to you. The downside of this is that you'll have to have Perl create the JavaScript for the pages displayed, which might take a lot of tinkering to stop syntax errors.

If you decide to use JavaScript, check out Netscape's Ultimate Client Sniffer for some sample code: developer.netscape.com/docs/examples/javascript/browser_type.html .

Cheers,
adam