Understanding Chrome Frame User Agent

Google Chrome Frame is no longer supported and retired as of February 25, 2014. For guidance on what you need to know as a developer or IT administrator, please read our developer FAQs for Chrome Frame.


Introduction

Chrome Frame has a dual identity in terms of User Agent in a sense that if looked from the server the web application will get Internet Explorer’s UA whereas the script running on the page will see Chrome’s UA. So here is what you can do to identify Chrome Frame from server or from the content.

A simple Test Page


The image shows a simple PHP test page (refer to the source below) that prints out user agent strings as seen from different points. 


Top Level User Agent  

For the top level page, the user agent is of the form:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; chromeframe/11.0.660.0)

This is Internet Explorer’s user agent with token ‘chromeframe/X.X.X.X’ appended in the ‘post platform’ section. Where the X.X.X.X is the version of Chrome Frame. 

Note: Chrome Frame works hard to make sure that the UA token is present consistently, however, sometimes it does not have complete control over where the token will end up in the UA string.  So in rare cases the UA might look like:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) chromeframe/11.0.660.0

Sub Resource Requests or Sub-frames

When a page is loaded in Chrome Frame, it loads sub resource requests like images or sub frames using Chrome’s user agent. A chrome frame token is also appended in this UA to allow distinction between Chrome Frame requests from Chrome requests.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; chromeframe/11.0.660.0) AppleWebKit/534.18 (KHTML, like Gecko) Chrome/11.0.660.0 Safari/534.18

Sending Chrome’s UA for sub resource requests allows pages with third party content work correctly. Third party content that is not aware of Chrome Frame sees this as a Chrome requests and will serve correct flavor of content.

From the script on the web page

To the script on the page, Chrome Frame appears exactly like Chrome. Well, it is running inside a first class sandboxed Chrome renderer.
The best way to detect if the content is running inside Chrome Frame is to check for the existence of window.externalHost This is a special object that exists only when Chrome is running in Chrome Frame mode. Note that since the script on the web page is running in Chrome, navigator.userAgent will return Chrome’s UA string.

Source Code

The source is a PHP script:

<?php
header("Cache-Control: no-store, no-cache, max-age: 0, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
?>
<html>

 <head>
   <title>Chrome Frame User Agent</title>
   <meta http-equiv="x-ua-compatible" content="chrome=1" />
 </head>
<body>
 <h3> Understanding Chrome Frame User Agent </h3>
 <p><b>User Agent, as seen for the top level page:</b>
   <br><?php echo $_SERVER['HTTP_USER_AGENT'] ?>
 </p>
 <p><b>User Agent, as seen for sub-resource requests
       like images or sub frames:</b><br>
 <iframe src ="ua.php" name="x" width="100%" height="60"> </iframe></p>
 <p><b>User Agent, as seen by the script on the page:</b></p>
 <script type="text/javascript"> document.write(navigator.userAgent); </script>
</body>
</html>

ua.php is:

<html>
 <body>
   <?php echo $_SERVER['HTTP_USER_AGENT'] ?>
 </body>
</html>



Č
ą
ua.jpg
(112k)
Robert Shield,
Feb 15, 2011, 3:17 PM
Comments