My favorites | English | Sign in

Faster apps faster - GWT 2.0 with Speed Tracer New!

Google Chrome Frame

Developer's Guide

About This Document

This document is for web developers who want their pages to work with Google Chrome Frame. In most cases, making your pages work with Google Chrome Frame is trivial: you just add a single tag to the page. This simple process is described in the section Making Your Pages Work with Google Chrome Frame. The rest of the document is devoted to advanced issues and options.

In short, if your page works in the Google Chrome browser, it'll work in Google Chrome Frame.

Making Your Pages Work with Google Chrome Frame

Making your pages work with Google Chrome Frame is easy. Just add this tag to the top of the page:
 <meta http-equiv="X-UA-Compatible" content="chrome=1">

That's it! Users running Internet Explorer with Google Chrome Frame installed will automatically have their pages rendered by Google Chrome Frame.

Detecting Google Chrome Frame and Prompting to Install

Google Chrome Frame reports that it is available by extending the host's User-Agent header to add the string chromeframe. You can use server-side detection to look for this token and determine whether Google Chrome Frame can be used for a page. If Google Chrome Frame is present, you can insert the required meta tag; if not, you can redirect users to a page that explains how to install Google Chrome Frame.

As an alternative to server-side sniffing, you can use the CFInstall.js script to detect Google Chrome Frame and prompt users to install the plug-in at runtime. Using the script is straightforward:

<body>
<script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"> </script>
 
<div id="placeholder"></div>

<script>
 CFInstall.check({
    node: "placeholder",
    destination: "http://www.waikiki.com"
  });
</script>
</body>

The document containing the script must include a body tag. In browsers other than Internet Explorer, the call to check() is a no-op. Note that you can't make a local copy of the JavaScript library and use it with a file:// URL - that won't work.

In Internet Explorer, check() determines if Chrome Frame is installed. If not, the user is prompted to install it. You can choose how you want the user to be prompted. By default, check() injects an iframe at the top of the page. This iframe will navigate to a "Please install Google Chrome Frame" page hosted by Google. The node parameter indicates where to place the iframe.

Once the user prompt is displayed, CFInstall examines the environment periodically to determine if the plug-in has finished installing. If it has, the browser is redirected to the destination URL. If no destination is provided, the current page is simply refreshed when Google Chrome Frame is detected.

CFInstall.check() Options

The CFInstall.check method has many more options. You can specify:

  • mode: optional. How the user should be prompted when Google Chrome Frame is missing. Defaults to inline but can also be set to popup to create a new window for the prompt.
  • url: optional. Set this to change the URL that the prompt (either inline or in a popup) will navigate to. You might use this if you're using Google Chrome Frame on an intranet or closed environment and you want to prompt users to install from an alternate location.
  • destination: optional. The URL to navigate to once CFInstall detects that Google Chrome Frame has been installed.
  • node: optional. The ID or reference to an element that will contain the iframe prompt. If no node is provided, the prompt iframe will be inserted at the top of the document.
  • onmissing: optional. Function that will be called when Google Chrome Frame is missing.
  • preventPrompt: optional. Boolean, defaults to false, which allows you to disable the default prompting mechanism. Use in conjunction with onmissing to implement your own prompt.
  • oninstall: optional. Function that will be called when Google Chrome Frame is first detected after an install prompt is displayed.
  • preventInstallDetection: optional. Boolean, defaults to false. Set this to true to prevent CFInstall from checking whether Google Chrome Frame has been installed. Use this to prevent redirection.
  • cssText: optional. Style properties to apply to the prompt iframe when mode is inline.
  • className: optional. CSS classes to apply to the prompt iframe when mode is inline.

Debugging Tools

You can use the Web Inspector in Google Chrome Frame just as you would in the Google Chrome browser. To use it, right-click and choose Inspect Element. Logging is available via the console.log method, and you can set breakpoints and inspect network activity.

Testing Your Sites

To make your pages work with Google Chrome Frame, you should use the method of inserting a meta tag, as described earlier. There are other ways of invoking Google Chrome Frame. These techniques are useful for testing and are not guaranteed to work in future versions.

Google Chrome Frame provides a fast testing and prototyping shortcut that's especially useful when you can't modify the page you want to test. To use this method, just navigate to the URL prepended with "cf:". Note that this prefix is in addition to any other URL scheme. For example, to see Gmail in Google Chrome Frame, go to Internet Explorer and navigate to:

cf:http://gmail.com

You must use both the cf: and http: prefixes.

You can also use the Windows Registry to force a URL to be loaded in Google Chrome Frame. Note that the URLs are registry values (and not sub-keys):
HKCU
  Software
    Google
      ChromeFrame
        OptInUrls
          *google.com*         [string value name is the pattern to match, assigned value is not used]
          *yahoo.com/mail*     [use simple pattern, no regexp matching]
          *                    ['*' means load everything!]

Note: forcing websites into Google Chrome Frame with these techniques may lead to unexpected behavior. Google Chrome Frame will fetch URLs using the host browser's network stack, so the web site will send content intended for the host browser. That may not always work well if rendered in Google Chrome Frame.

By default, Google Chrome Frame uses Internet Explorer's network stack to fetch url requests. This ensures the user sees only one view of cookies, history, SSL state, and so on. To turn this off, add a 'DWORD' value 'UseChromeNetworking = 0' under HKCU\Software\Google\ChromeFrame.

Google Chrome Frame sends all top level navigation to Internet Explorer. This is to allow content to load other links in the host browser. This feature can be turned off by adding a DWORD value 'HandleTopLevelRequests = 0' under HKCU\Software\Google\ChromeFrame.

Known Issues

Google Chrome Frame is a work in progress. Many features and APIs are still in a state of flux. The following are known issues:

  • Printing is not yet implemented.
  • Downloads initiated from Google Chrome Frame are downloaded, but neither the Google Chrome nor the host browser UI is displayed.