Forum Moderators: open

Message Too Old, No Replies

Checking to see if browser is mobile

         

supermanjnk

12:50 pm on May 24, 2005 (gmt 0)

10+ Year Member



I'm working on a site that will most likely be accessed using mobile devices. However, it will also be accessed using a standard browser. I was wondering if there was a way to check if the browser is mobile, and if it is exclude a certain bit of code (images mostly)

MatthewHSE

1:11 pm on May 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I know nothing about mobile browsers, have never used one, but I would think you could test the UA string and use server-side scripting to send different content to different browsers. Someone else may have a better idea, though, such as using the "handheld" media type with CSS.

tedster

1:21 pm on May 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is, unfortunately, not a straighforward issue for at least two reasons:

1. Many handheld user agents will spoof their identity and then take the fullscreen page and do what they want to with it im order to adapt it to their proprietary rendering standards.

2. If you try to use javascript to measure the available screen size, you will discover that many handheld browsers come with javascript disabled by default.

Ideally, the solution would be a full implementation of the CSS2 media="handheld" - but here we currently have a bit of an impasse.

Because so few page authors are creating their pages with alternate css for handhelds, the handheld browsers do not yet support it (Opera a notable exception). And of course, because there is minimal support from the user agents, developers do not yet invest the resources to create the handheld css file.

firstreflex

2:35 pm on May 25, 2005 (gmt 0)

10+ Year Member



If you try to use javascript to measure the available screen size, you will discover that many handheld browsers come with javascript disabled by default.

Have a basic style sheet with images display:none, handheld devices will pick this up. Use javascript to detect larger screen sizes and send those users the full stylesheet.

tedster

2:40 pm on May 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Aha! Good thinking on that approach.

Krapulator

4:07 am on May 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Except that normal browsers with javascript disabled will not see any of the images.