Contents
About This DocumentThis document is for web developers who want their pages to work with Google Chrome Frame (aka, GCF). In most cases, making your pages work with GCF is trivial: you just add a single tag to the page. This simple process is described in the next section. 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 GCF. For more information check out FAQ.
Making Your Pages Work With Google Chrome FrameMaking your pages work with GCF is easy. Just add this tag to the top of the page:
For many sites, adding a tag to every page may be cumbersome, so GCF also supports detection through an HTTP header with the same name and value:
You may recognize the X-UA-Compatible flag as the same mechanism introduced with IE 8 for controlling the rendering engine that IE uses for a particular page. In cases where GCF is not installed, the values can be combined to control IE's rendering behavior:
Note that the value for the "IE" parameter must be provided first. Also, please note that no matter where in the order you list the value "chrome=1", GCF will render the page if it is installed. That is to say, the switch to render the page in GCF always takes the highest priority. To deploy this header site-wide for a site served with Apache, ensure that mod_headers and mod_setenvif are enabled and add the following to your httpd.conf (or appropriate configuration file):
For IIS 7.0 and greater, you can set the header in a web.config file with similar syntax:
Conditional Google Chrome Frame ActivationDepending on your site's needs, you might only want to use Google Chrome Frame for users with certain versions of IE. The following X-UA-Compatible header values (whether in a meta tag, or in the HTTP headers) provide you with this control:
The differences between Chrome and Chrome FrameThere are a few subtle differences between the two. Read up on the details at Differences between Chrome and Chrome Frame. Detecting Google Chrome Frame and Prompting to InstallGCF reports that it is available by extending the host's User-Agent header with the stringchromeframe . For more information see Chrome Frame User Agent.You can use server-side detection to look for this token and determine whether GCF can be used for a page. If GCF is present, you can insert the required meta tag; if not, you can redirect users to a page that explains how to install GCF.As an alternative to server-side sniffing, you can use the CFInstall.js script to detect GCF and prompt users to install the plug-in without restarting their browsers. Using the script is straightforward:<html> 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 br at the top of the page. This br will navigate to a "Please install Google Chrome Frame" page hosted by Google. The overlay mode specified in the example ensures that this UI is displayed over other page content in a modal way and gives the user controls to disable the prompt for the site (noted for the future in a cookie).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 GCF is detected. If the page was served with either the meta tag or HTTP header, the refreshed page will then render in GCF and the subsequent call to check() will not trigger the prompt.CFInstall.check() OptionsTheCFInstall.check method has many more options. You can specify:
CFInstall ExamplesUsing the node parameter with an inline prompt to place the prompt br in the page and using CSS to style the br, reloads the current page when install finishes:
Note the use of the IE-specific conditional comment syntax. This syntax prevents the code inside it from being visible to non-IE browsers. This avoids fetching the CFInstall script and running the checks on browsers that don't need them, speeding up your pages. Notably, if this page is served with the GCF meta tag or header and the page renders using GCF, the conditional comments will also be ignored, meaning that it's safe to wrap CFInstall-specific code in conditional comments. Easier method to enable Chrome Frame for specific versions of Internet Explorer is explained in the FAQ: www.chromium.org/developers/how-tos/chrome-frame-getting-started/chrome-frame-faq#TOC-How-can-I-enable-Google-Chrome-Fram1 Screenshot of promptHere is how the prompt looks in mode:"overlay" :Debugging ToolsYou can use the Web Inspector in GCF just as you would in the Google Chrome browser. To use it, right-click and choose "Inspect Element". Logging is available via theconsole.log method, and you can set breakpoints and inspect network activity.Testing Your SitesTo make your pages work with GCF, you should use the method of inserting ameta tag, as described earlier. There are other ways of invoking GCF. These techniques are useful for testing but are turned off by default. GCF 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 "gcf: ". Note that this prefix is in addition to any other URL scheme. For example, to see Gmail in GCF, go to Internet Explorer and navigate to:gcf: |