Javascript and Screen Sizes

With mobile browsers becoming more and more prevalent, it becomes more and more necessary to develop a version of your Web site for those browsers. There are a lot of scripts out there that are designed to detect mobile browsers, but many of them need to be updated every time a new mobile browser is developed.

A quick and easy way to detect mobile browsers is to detect the users’ display resolutions. Certainly, this is far from flawless, but it’s not a bad method. Assuming that the browser supports javascript, you can easily figure out the users’ resolutions by using the screen.width and screen.height properties. You can fairly safely assume that most users with a screen width of less than 600 pixels is viewing your site with a handheld of some sort. Therefore, you should use the following javascript to perform any special actions that need to be taken when being viewed with a handheld.

<script type="text/javascript">
if(screen.width <= 600) {
mobileSite();
}
</script>

In my case, I’m using a similar script to determine whether or not TinyMCE should be initiated or not. My TinyMCE init script looks like:

<script type="text/javascript">
if(screen.width>600) {
tinyMCE.init();
}
</script>

I hope that helps some people.

Sega Rumors Fly

Some very big rumors about Sega have been circulating on the Internet over the past few days. Most of those rumors have centered around the idea that Sega will be developing and releasing a handheld gaming device next year, attempting to rival the Sony PSP. Gizmodo even took the bait and ran with it. There was, apparently, even a shoddily produced video supposedly showing the new “Vision” in action. The video has since been removed from YouTube.

However, from what I’ve been able to ascertain, most of those rumors are false and have been blown way out of proportion. CrunchGear ran a couple of articles trying to get to the bottom of the situation. In the end, Unofficial RPG posted seemingly official quotes from Sega officials confirming the existence of the Vision handheld, but stating that it was simply going to be a portable media player rather than a new handheld game console.

As of yet, there is still no official word on Sega’s Web site, so it is very difficult to ascertain how much fact and how much fiction are involved in this story. I, for one, will be one waiting with baited breath to see if Sega really does dip its toes back into the hardware game.