breadcrumbs: Chromium > page_name: chromecompatfaq title: Fixing Google Chrome compatibility bugs in websites - FAQ
The list is based on analysis of a large number of real-world sites with compatibility issues. It‘s important to note that in nearly all cases we’ve seen, the fixes required to get a Website working well in Google Chrome have been minimal. Developers are often surprised that problems that looked like they could take weeks of developer time were often solved in under an hour and matched closely with the list below.
Each item is described along with its solution, at the end we have a section that lists useful tools and points of reference that you may find useful in diagnosing problems.
Google Chrome uses WebKit (http://webkit.org/) to draw Web pages. WebKit is a mature (~9 years) open source layout engine used by Apple (Safari, iPhone), Google (Android, Google Chrome), Nokia and many other companies. Google Chrome aims to render sites exactly like Safari. This means that if your site works in Safari there is a large chance it will work in Google Chrome and vice versa.
Page not displayed correctly in Google Chrome, or you get a message noting that Google Chrome is not a “supported browser”.
By far the most common problem we see is JavaScript (or server-side) code that tries to detect the browser by looking at the navigator.userAgent string. Often the checks used are buggy and do not identify Google Chrome correctly.
Do everything you can to avoid this, parsing navigator.userAgent and navigator.vendor is notoriously bug-prone and usually the wrong thing to do! Object detection is a much safer method to achieve per-browser behavior...
On Windows, Google Chrome's useragent string looks something like the following: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/2.0.167.0 Safari/525.13
In nearly all cases you don‘t want to check if you’re running under Google Chrome, but if the browser is using the WebKit rendering engine (see above). If you must look at the navigator.userAgent string look for the substring ‘AppleWebKit’, nothing else is guaranteed to continue working in the future!!
var isWebKit = navigator.userAgent.indexOf(“AppleWebKit”) > -1;
isWebKit will be true if you're running in Google Chrome, Safari or any other browser using WebKit.
To check the version of WebKit, use:
var WebKitVersion = parseFloat(navigator.userAgent.split(“AppleWebKit/”)[1]) || undefined; if (WebKitVersion && WebKitVersion > 500 ) { // use spiffy WebKit feature here }
You can find a list of Google Chrome Releases and their corresponding WebKit revisions here.
if (isChrome) { doSomethingChromeSpecific(); } else { // Didn't detect browser type, so assume IE. doSomethingIESpecific(); }
The problem is that the above snippet assumes that any browser not explicitly identified is IE. The problem is that it's far more likely for other browsers to act alike than it is for them to act like IE. And IE9 is very similar to all other browsers, so the code fork is bound to fail. Stick to feature detection instead.
A single line header wraps over multiple lines, messing up a site's layout. Text gets cut off or overlaps other elements.
HTML & CSS can't do pixel perfect layout. So font and element sizes can change slightly between browser versions and OSs. If a site depends on a font being an exact size then text can get cut off or wrap on other browsers or OSs.
Whenever possible, make use of dynamically sized elements rather than specifying fixed pixel widths. This is often easier said than done, but it ensures that content will adapt well to all browsers. Test your site in multiple browsers and OSs, enlarge fixed pixel width elements to accommodate the maximum size you see. Use the white-space:nowrap css attribute to ensure that single line headings don't wrap over multiple lines.
Your page looks garbled in Google Chrome. Garbage characters may be displayed, and RTL language pages (e.g. Hebrew or Arabic) may appear with their letters reversed.
If character encoding is not specified precisely, different browsers can interpret the encoding in different ways or not at all. The impact on users is dire since it prevents them from viewing the site.
Plug-ins, such as Flash videos, Windows Media Player movies, or Java applets, do not appear in Google Chrome, but do appear in Internet Explorer.
There are 2 types of plugins on Windows: ActiveX & NPAPI. IE uses ActiveX plugins, all other browsers (including Google Chrome) use NPAPI plugins. ActiveX is Windows-only, plugins on other platforms usually use NPAPI.
<object ...>
This embeds a flash video. IE will use the parameters in the object tag and thus will load the file flash_ad.swf. All other browsers will use the embed tag and play different_file.swf. Another common error is to specify different values for the transparency attribute when embedding flash.
Some CSS styling does not work in Google Chrome, even though they seem fine in IE or Firefox.
Each browser has its own private CSS selectors and JavaScript objects. Use of these types of markup is, by definition, not compatible with other browsers. These should only be used for non-critical tasks (e.g. adding text shadows). It is safest not to use them at all.
We've found the following tools extremely useful when diagnosing compatibility problems with Websites. Using them can greatly decrease the amount of effort and guesswork that goes into fixing compatibility issues: