# Determining Browser?

**URL:** <https://www.ruby-forum.com/t/determining-browser/55523>\
**Category:** Rails\
**Created:** [March 21, 2006, 8:54pm UTC](https://www.ruby-forum.com/t/determining-browser/55523 "2006-03-21T20:54:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [March 21, 2006, 8:54pm UTC](https://www.ruby-forum.com/t/determining-browser/55523/1 "2006-03-21T20:54:39Z")

</div>

Is there a way I can read the user agent or something similar to  
determine whether the person is using IE, Mozilla/Netscape, Opera,  
Safari, etc? I want to dynamically output the CSS to the browser, but  
I’d like to change certain things (in this case the widths of some  
divs since IE adds borders and padding size to the total size of a div  
unlike firefox).

Thanks,

- Brent

---

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [March 21, 2006, 9:03pm UTC](https://www.ruby-forum.com/t/determining-browser/55523/2 "2006-03-21T21:03:34Z")

</div>

check that…

if (request.env[‘HTTP\_USER\_AGENT’].include?(“IE”))  
#internet explorer  
end

By the way: could you invite me to gmail?

Regards  
Peter

---

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [March 21, 2006, 9:07pm UTC](https://www.ruby-forum.com/t/determining-browser/55523/3 "2006-03-21T21:07:59Z")

</div>

here’s a (somehow boring) list of browser id’s

[http://www.zytrax.com/tech/web/browser\_ids.htm](http://www.zytrax.com/tech/web/browser_ids.htm)

---

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [March 21, 2006, 10:55pm UTC](https://www.ruby-forum.com/t/determining-browser/55523/4 "2006-03-21T22:55:58Z")

</div>

Thanks, thats quit an extensive list. I really only care about IE,  
Firefox/Mozilla/Netscape, Opera and Safari. But how do I read the  
user agent in RoR? I checked the request object and poked around  
searching the wiki and I can’t find a way. I’m sure there is, I’m  
just looking over it I think.

- Brent

---

<div class="post-metadata">

**Author:** ![Brent\_J](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Brent\_J](https://www.ruby-forum.com/u/Brent_J)\
**Post date:** [March 21, 2006, 11:12pm UTC](https://www.ruby-forum.com/t/determining-browser/55523/5 "2006-03-21T23:12:58Z")

</div>

Oops, sorry! Didn’t see this response since gmail folded it up, and  
yes, invite sent.

Thanks!

- Brent
