Multiple Browser Coding Guidelines

The features of different Web browsers, such as CSS and JavaScript support, can cause Web applications to work differently from one browser to another. This lack of continuity among browsers not only causes an application to look bad, but it often causes it to break. Acid3 is a test from the Web Standards Project that checks how well a web browser follows certain selected elements from web standards, especially relating to the Document Object Model (DOM) and JavaScript.

Acid3 Test

Acid3 test focuses on technologies used on modern, highly interactive websites characteristic of Web 2.0, such as ECMAScript and DOM Level 2. Controversially, it includes several elements from the CSS2 recommendation that were later removed in CSS2.1 but reintroduced in World Wide Web Consortium(W3C) CSS3 working drafts that have not made it to candidate recommendations yet.

Layout Engine

Browser

Acid3 Score

Presto

Opera 10

100/100

WebKit

Safari 4.0

100/100

Chrome 4.0

100/100

Gecko

 

Firefox 3.5.7

93/100

Firefox 3.6

94/100

Firefox 3.7

96/100

Firefox 4.0

?/100

Trident

 

IE 6.0

12/100

IE 7.0

14/100

 

IE 8.0

20/100

IE 9.0

32/100

 

Tool of Choice

 One can handle most of the browser issues by using hacks but hacks are dangerous. Since they are based on non-standard exploits, you can’t predict how they are going to behave in future browsers. The tool of choice for fighting these problems is the conditional Stylesheet and JavaScript. Browsers provide comment tags, to target specific versions, as well as greater-than/less-than stuff for targeting multiple versions at once.

Conditional Stylesheets and JavaScripts

The core idea is based on the method of Conditional Comments found in Internet Explorer, extended to include other browsers, and to move the conditional statements inline with your CSS definitions.

Conditional-CSS isn’t really all that interested in which browser the user using, but rather what is rendering engine the user’s browser utilises. This is why Conditional-CSS uses ‘Gecko’ rather than the well known Firefox as one of it’s browser conditions. Likewise for Safari ‘Webkit’ is used. This allows other browsers using the same rendering engines to receive the same targeted CSS. An exception to this rule is made for IE (rather than using ‘Trident’) since this is what the IE conditional comments use and Trident isn’t particuarly well known. Similarly for Opera, since only the Opera browser uses it’s Presto rendering engine, ‘Opera’ is used.

How to go about it?

  1. Choose one of the standard conforming browsers (Acid3 score 100/100) like Chrome 4.0 or Opera 10 to create and test a standard compliant Stylesheets and JavaScripts common for all browsers.
  2. Create a separate Stylesheet and Javascripts for each of the browser versions you want to target e.g. IE and Firefox versions..
  3. Include the Stylesheets and JavaScripts from step 2 by using conditional comments. This overrides the statements in the common CSS and javaScript file created in step 1.

<!–[if IE]> <style type=”text/css”>@import “IE-override.css”;</style> <![endif]–>

This CSS file is only loaded if the detected browser is IE, otherwise it won’t. You should put this conditional statement into the head of your html file after every other CSS import code. It should be the last in the list, so that it overwrites the main css files:

Now if for example you had a statement in your main.css file: #logo { margin:10px } and it doesn’t work properly in IE, you can add the same statement with a different value in your IE-override.css file: #logo { margin:20px }.

The Conditional Comment Code Examples

The syntax to note is “!” stand for “not”, so !IE means “not IE”. gt means “greater than”, gte means “greater than or equal”, lt means “less than”, lte means “less than or equal.”

Target ALL VERSIONS of IE

<!–[if IE]>

            <link rel=”stylesheet” type=”text/css” href=”all-ie-only.css” />

<![endif]–>

Target everything EXCEPT IE

<!–[if !IE]>

            <link rel=”stylesheet” type=”text/css” href=”not-ie.css” />

<![endif]–>

Target IE 7 ONLY

<!–[if IE 7]>

            <link rel=”stylesheet” type=”text/css” href=”ie7.css”>

<![endif]–>

Target IE 6 ONLY

<!–[if IE 6]>

            <link rel=”stylesheet” type=”text/css” href=”ie6.css” />

<![endif]–>

Target IE 6 and LOWER

<!–[if lt IE 7]>

            <link rel=”stylesheet” type=”text/css” href=”ie6-and-down.css” />

<![endif]–>

<!–[if lte IE 6]>

            <link rel=”stylesheet” type=”text/css” href=”ie6-and-down.css” />

<![endif]–>

Target IE 7 and LOWER

<!–[if lt IE 8]>

            <link rel=”stylesheet” type=”text/css” href=”ie7-and-down.css” />

<![endif]–>

<!–[if lte IE 7]>

            <link rel=”stylesheet” type=”text/css” href=”ie7-and-down.css” />

<![endif]–>

Target IE 8 and LOWER

<!–[if lt IE 9]>

            <link rel=”stylesheet” type=”text/css” href=”ie8-and-down.css” />

<![endif]–>

<!–[if lte IE 8]>

            <link rel=”stylesheet” type=”text/css” href=”ie8-and-down.css” />

<![endif]–>

Target IE 6 and HIGHER

<!–[if gt IE 5.5]>

            <link rel=”stylesheet” type=”text/css” href=”ie6-and-up.css” />

<![endif]–>

<!–[if gte IE 6]>

            <link rel=”stylesheet” type=”text/css” href=”ie6-and-up.css” />

<![endif]–>

Target IE 7 and HIGHER

<!–[if gt IE 6]>

            <link rel=”stylesheet” type=”text/css” href=”ie7-and-up.css” />

<![endif]–>

<!–[if gte IE 7]>

            <link rel=”stylesheet” type=”text/css” href=”ie7-and-up.css” />

<![endif]–>

Target IE 8 and HIGHER

<!–[if gt IE 7]>

            <link rel=”stylesheet” type=”text/css” href=”ie8-and-up.css” />

<![endif]–>

<!–[if gte IE 8]>

            <link rel=”stylesheet” type=”text/css” href=”ie8-and-up.css” />

<![endif]–>

Oracle OLAP Option

The Oracle 10g Enterprise Edition OLAP Option extends the analytic capabilities of the Oracle database by providing new multidimensional datatypes, a multidimensional calculation engine, and a framework to build OLAP applications using SQL, PL/SQL and Java. Uniquely, the OLAP Option uses the Oracle database to store and manage its data, allowing you to take advantage of the scalability, reliability and manageability of the Oracle 10g platform.

How To Create an IE-Only Stylesheet

The tool of choice for fighting IE problems is the conditional stylesheet. IE provides comment tags, supported all the way up to the current IE 8 to target specific versions, as well as greater-than/less-than stuff for targeting multiple versions at once.

Why use conditional stylesheets?

1.    Create a stylesheet and javascript common for all browser, without using any hacks to work around rendering problems in MSIE
2.    Create a stylesheet and javascripts common for all versions of MSIE.
3.    Create a separate stylesheet and javascripts for each of the MSIE versions you want to target.
4.    Include the stylesheets and javascripts from 2 and 3 by using conditional comments.

One good example can be found at http://www.gpuri.com

Inject Google analytics code in HTML pages

To update your HTML/JSP/PHP pages with the google analytics you can
use UNIX sed command and inject the two scripts provided for your
website by google analytics. Below is the code. This code replaces
</body> tag with the scripts and </body> tag.

find ./ -type f -iname “*.htm” | xargs sed -i ’s/<\/body>/<script
type=\”text\/javascript\”> var gaJsHost = \(\(”https:” ==
document.location.protocol\) ? “https:\/\/ssl.” : “http:\/\/www.”\);
document.write\(unescape\(”%3Cscript src=’\”” + gaJsHost +
“google-analytics.com\/ga.js’\” type=’\”text\/javascript
‘\”%3E%3C\/script%3E”\)\);
 <\/script><script type=”text\/javascript”> try { var pageTracker
 = _gat._getTracker\(”UA-XXXXXXX-X”\); pageTracker._trackPageview\(\);
 } catch\(err\) {}<\/script> <\/body>/g’

Reduce code noise with Groovy

Groovy’s concise syntax frees developers from typical Java™ constructs that are required for code compilation but don’t facilitate expressing what a program is really trying to accomplish. In this revival of the Practically Groovy series, Groovy developer and guest columnist J. Scott Hickey walks you through a series of comparisons between normal Java code and the same Groovy code to show you how this exciting language frees you to focus on the important aspects of coding.

JBoss ESB

If SOA is too expensive, complex or politically challenging, the technology won’t take off. How, then, is it possible to build an SOA that overcomes political and cost constraints? Driving an SOA strategy to success in a large organization requires a corporate-level CIO with the power to drive a vision, enforce a set of architectural goals and blueprints, and mediate financial allocations. To get a manageable SOA, you’ll need to start with SOA platforms that represent a relatively low investment. That’ll likely mean tools and platforms that are open source, with support and ecosystem benefits available at a low cost.

JBoss team have designed their own Service Bus: JBoss Enterprise Service Bus  is a robust SOA solution designed since the release 4.2 with build-in fail-over, load balancing and delayed message redelivery. JBossESB allows you to distribute service instances across many nodes. Each node can be a virtual or physical machine running one or more instances of JBossESB.

How to use the agent sample application in WebLogic 10 - OpenSSO

This document describes to use the agent sample application in conjunction with the Weblogic 10.X Application Server and the J2EE Agent. Please note thatthe agent needs to be installed first before deploying this sample application.

OpenSSO Fedlet Demo

I will try to demonstrate an IDP generating Fedlets, SP configuring and using this Fedlet for IDP initiated SSO, SP initiated SSO and transfer of identity attributes as part of the assertions from the IDP.

Here’s also the details and a write-up of steps of steps, which I’ve used for the setup.

Using Adobe Flex in JSR-286 Portlets

This article shall show you how the Adobe Flex SDK can be used in a Portal environment to enhance the user interface for a Portlet. It has also previously been possible to use Flex with JSR-168 Portlets and alike [FlexPortal], but with the new Portlet 2.0 specification (JSR-286) some things have improved, such as the support for asynchronous requests, public render parameters and events. It will be shown what is possible with the technology combination Flex/Portlets and where the limits are.

JBoss Federated SSO

The JBoss SSO Framework is a collection of components that software developers can easily integrate within their existing web applications to create a federation of trusted web sites. The framework has support for important SSO standards such as SAML.

Next Page →