Forum Moderators: mack

Message Too Old, No Replies

Needed: Server Side Redirect Based on Browser Resolution

server side resolution redirect script

         

SymbioticDesign

1:55 am on Dec 29, 2003 (gmt 0)

10+ Year Member



Hello All...

NOTE: Please understand that I am NOT a developer. I am very used to coding HTML, even within PHP/Perl pages. But I can only modify Perl/PHP script code to suit a little.

My problem is that I want to accomodate mobile platforms. As a designer, I've re-designed my site at least three times. However, all redesigns look like yuck (subsitute bad word for yuck) in an Internet ready mobile device.

In order to accomodate mobile platforms, I have to target tiny browser resolutions (240 by 268 pixels, or 176 by 280). This would be easily done with Javascript or CSS, but most PDA and phone browsers don't yet support Javascript and have poor support for CSS.

That rules out the two avenues that I am used to taking. Obviously, I need a server side solution. My server (Apache Version 1.3.27, Linux Redhat Version 7.3) supports Perl 5.6.1 and 4.2.3 w/Zend Optimizer v2.0.2, MySQL, Python and Java Servlettes.

I thought PHP would handle this, but everywhere I go, this seems not to be the case. I'm told that PHP can detect a browser client version (Moz 4/5/6, etc..), but not a screen resolution? For sure, I haven't been able to come up with any scripts, examples, or tutorials about doing this in PHP (Google insists on showing me Javascript that does this, but when I search for variations of "PHP resolution redirect script" in quotes, there are never any finds.

So, I assume I should give up on trying to use PHP to reslove this predicament? If so, what should I use? Is Perl capable of this? I understand that Java Servlets are capable, but writing code for Java Servlets is a time consuming headache and the scripts run a little slower?

Please point me in the right direction.

Thank you. Sincerely, Doug Peters

o0sagar0o

12:59 pm on Dec 29, 2003 (gmt 0)



I don't know which browser or device you use to test the HTML pages that your are developing.

But you can easily create pages for mobile devices using simple HTML and CSS.

You should try using the Opera browser to develop such pages. You can easily view how the page would look in a mobile platform. Simply press Shift+F11

For a great example, you should check [my.opera.com...]
The same page works great on cell phones and computers.
All done using CSS. :)

amznVibe

1:44 pm on Dec 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can't detect screen resolution via server side only scripts (php, perl) because the client browser (javascript, java) is the only one that knows its resolution.

However you can *guess* the min/max screen resolution based on the user agent that you pickup serverside via php. There has to be a good list of tiny browser user-agents somewhere on Google (or here for that matter).

By the way, anyone with a browser that small already is probably already using special services to see complex sites in a normal way. There are several services out there that even do this for free, including Google itself.

You can fire up Opera (only major browser that can do wap/wml) go to [wap.google.com...]
and enter your website url and see what Google makes of it with it's proxy.

SymbioticDesign

6:21 pm on Dec 29, 2003 (gmt 0)

10+ Year Member



#1) I know how to write HTML and CSS for tiny screen resolutions. I think I was clear on that.

#2) So, what if client's browser has the information on his side? Ever hear of $_SERVER["HTTP_USER_AGENT"]? This is used in PHP to identify the user's browser. PHP can get this information and use it. Here is the PHP tutorial that shows how to do it:
[us3.php.net...]

#3) If I design my web page to look good on a PDA, do you realize how poor it will look on a PC? Even an 800x600 resolution would suck (the smallest XP resolution). 640x480 wouldn't make it all that more impressive either, and only Win 95/98 ran that.

#4) Google does this. If Google detects a PDA device, it serves up [mobile.google.com...] or some other PDA subdomain designed especially for mobile devices.

Obviously, this can be done. I would have thought that the server-side script would have detected the screen resolution. If it is using $_SERVER["HTTP_USER_AGENT"], then it has to run through a very long list of possible HTTP user agents.

Maybe that's what is happening, Google certainly does have the Gonads to be able to pull that off. Darn. It sounds so simple to redirect based on the HTTP user agent's screen resolution, then you don't have to worry about constantly updating a huge library of thousands of browser types.

But it does have to be done on the server side because PDA and phone devices capable of browsing the internet have no client based scripting language, yet. CSS and javascript are NOT supported, yet.

Drat, drat, double drat.

txbakers

6:27 pm on Dec 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Create two sites, one for PDA, one for desktops.

Read the user agent and redirect based on that.

end of discussion.

SymbioticDesign

6:38 pm on Dec 29, 2003 (gmt 0)

10+ Year Member



Yeah, thanks. That won't be pretty (or fun). One page for regular computers and one page for PDA's was always the solution, getting there was the dilemna. I'll just have to find an http user agent library somewhere, I guess.

-Thanks, everyone.

txbakers

6:39 pm on Dec 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No it's not pretty, but I don't see how anyone can expect one set of code to do the job.

One screen is big, the other the size of a post-it.

One computer can handle complex scripting and validation etc., the other can basically show HTML.

CSS is fine for output of the display, but doesn't address the coding behind the HTML/CSS.

I had to do this once with two sites.

SymbioticDesign

10:21 pm on Dec 29, 2003 (gmt 0)

10+ Year Member



Maybe I'll get a Java Developer to do it for me. LOL!

amznVibe

1:04 am on Dec 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Anyone that has use a content management system knows how this is fairly easy to do with them. You just have two templates, one for regular visitors and the other for pda style viewing. It's the same way programs like movabletype do xml/rss output while they can also generate regular html pages.

So you might want to look into using a CMS for your site if tiny screen support is that important to you.

SymbioticDesign

4:01 am on Dec 30, 2003 (gmt 0)

10+ Year Member



Interesting. I do use phpwebsite for one Domain. But it's extremely limiting for a variety of different web designs on different theme pages within that same site. I am also setting up WSN Links (Directory/Portal), which can be setup as a CMS (and often is) and does have RSS news feed support.

But I also like to have full control over my pages. Still, if WSN Links supports this, that might be nice. Then again, another option is also possible. What CMS systems do you suggest? I honestly am not interested in being able to update the site with templates/themes/skins, but I am not against it, either. CSS and offline Dreamweaver Templates have worked out very well for me, thus far. But if I could find something just to take care of that and let the rest fly, that would be great.

-Thanks