How can I detect if the app is accessed from mobile?

Hi,

I want to make the divs of my views to take 100% width for mobile
browsers and something else for “pc”.

How can I detect that? Any hints?

Thanks!

On Jun 22, 2008, at 1:56 AM, comopasta Gr wrote:

I want to make the divs of my views to take 100% width for mobile
browsers and something else for “pc”.

How can I detect that? Any hints?

Use JavaScript to detect browser type.

Google
detect browser agent
detect mobile browser agent

– gw

On Jun 22, 2008, at 2:22 AM, Frederick C. wrote:

browsers can be extremely quirky.
Sure. I’ve had pretty good luck in detecting all the big ones Palm,
Symbian, Windows Mobile, etc. So, similar to the way most apps are
tuned for IE/FF/and hopefully Safari, I focus on mobile looking at
least decent on the more common platforms–and of course generally
stick to some pretty basic layouts and attempts to use markup to
start with (looks better, faster, etc).

– gw

On 22 Jun 2008, at 10:08, Greg W. wrote:

On Jun 22, 2008, at 1:56 AM, comopasta Gr wrote:

I want to make the divs of my views to take 100% width for mobile
browsers and something else for “pc”.

How can I detect that? Any hints?

Use JavaScript to detect browser type.
athough of course javascript and css manipulation on some mobile
browsers can be extremely quirky.

Fred

How are the users accessing the app? if it is through http from their
mobile device, you could you use a service like handsetdetection.com

Greg W. wrote in post #692457:

On Jun 22, 2008, at 1:56 AM, comopasta Gr wrote:

I want to make the divs of my views to take 100% width for mobile
browsers and something else for “pc”.

How can I detect that? Any hints?

Use JavaScript to detect browser type.

Google
detect browser agent
detect mobile browser agent

– gw

CSS would be much, much simpler for this:

div {
width: 80%;
}

@media handheld {
div {
width: 100%;
}
}

Take a look of this link:

http://www.arctickiwi.com/blog/mobile-enable-your-ruby-on-rails-site-for-small-screens