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!

Use JavaScript to detect browser type.

Google
   detect browser agent
   detect mobile browser agent

-- gw

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

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

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 Willits wrote in post #692457:

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