The Artima Developer Community
Sponsored Link

Java Buzz Forum
Nokia's Multi-Platform Style Sheet Example

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Russell Beattie

Posts: 727
Nickname: rbeattie
Registered: Aug, 2003

Russell Beattie is a Mobile Internet Developer
Nokia's Multi-Platform Style Sheet Example Posted: Dec 19, 2003 6:42 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Russell Beattie.
Original Post: Nokia's Multi-Platform Style Sheet Example
Feed Title: Russell Beattie Notebook
Feed URL: http://www.russellbeattie.com/notebook/rss.jsp?q=java,code,mobile
Feed Description: My online notebook with thoughts, comments, links and more.
Latest Java Buzz Posts
Latest Java Buzz Posts by Russell Beattie
Latest Posts From Russell Beattie Notebook

Advertisement
This is kinda neat... Nokia just published a tutorial on how to target content for different browsers - by making the style sheet a dynamic jsp page. I can honestly say that I never thought of doing it this way.

Here's their code in a nutshell:

style.jsp:

<%
boolean smallbrowser = true;
String userAgent = request.getHeader("user-agent");

// Internet (Big) Browser
if ( userAgent.indexOf("Mozilla") != -1 ) {
%>
.hdr	{ 
            font-style: bold;
            font-size: 30px;
            text-align: center; 
            color: yellow;
            text-decoration: blink;
        }

<% 
    // Mobile (Small) Browser
    } else { 
      
      if ( (userAgent.indexOf("5100") != -1) || (userAgent.indexOf("3300")!=-1)) {
        //Nokia 5100 - Series 40 browser
%>
.hdr	{ text-align: center; }

<%
      } else if (userAgent.indexOf("3650") != -1) {
%>

.hdr	{ 
            font-style: bold;
            font-size: larger;
            text-align: center; 
        }


<% 
      } 
    }
%>

I think it's obviously a *lot* more complex of an issue than just this simple example, but I think there's a core of a solution here which is pretty neat. My only real concern is content length. Even if you stick to the XHTML-Basic for your markup (thus working just about everywhere), the size of the document can screw up many browsers. You almost need a completely new page per device type.

Making a new custom dynamic page per phone, however, is *really* a lot of work, so shortcuts like this are definitely welcome. I'd probably use DELI or WURFL instead of just a basic User-Agent test as well. But like I said, the idea is there and it's interesting...

-Russ

Comment

Read: Nokia's Multi-Platform Style Sheet Example

Topic: The Peter Principle: software developers version Previous Topic   Next Topic Topic: Eye of the Tiger - Generics in J2SE 1.5

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use