23
Sep
09

Turn on Chrome Frame for Internet Explorer in WordPress (and bbPress)

Google is promoting their Chrome “frame” enhancement for Internet Explorer users that allows people to stay with the IE interface but run the much faster and safer Chrome browser inside it.

However ChromeFrame has to be turned on for each website they visit.

To turn it on in WordPress and bbPress you should be able to add this single line as a mini-plugin, or in header.php or even in functions.php.


<?php if (strpos($_SERVER['HTTP_USER_AGENT'],"chromeframe")) {header("X-UA-Compatible: chrome=1");} ?>

Update: the above will not work, apparently Chrome needs it to be a META tag and not in the page headers :-( – thanks Matt

If you want to just put it in header.php use this (before </head>)

if (strpos($_SERVER['HTTP_USER_AGENT'],"chromeframe")) {echo '<meta http-equiv="X-UA-Compatible" content="chrome=1" />'}

If you want it to be a real plugin, use this:

<?php
add_action('bb_head','chromeframe');
add_action('wp_head','chromeframe');
function chromeframe() {
if (strpos($_SERVER['HTTP_USER_AGENT'],"chromeframe")) {echo '<meta http-equiv="X-UA-Compatible" content="chrome=1" />';}
}
?>


7 Responses to “Turn on Chrome Frame for Internet Explorer in WordPress (and bbPress)”


  1. September 25, 2009 at 2:14 am

    Just so you know, Chrome Frame doesn’t currently support triggering via a header like that, you can only activate it with the meta tag or sending the application/chrome mime type.

  2. September 25, 2009 at 2:29 am

    Wow, that’s not good. Must be a limitation of it running as a plugin in IE.

    Well a few more lines and running it as a formal WP/bbPress plugin will solve that but it’s unfortunate it needs the added complexity.

    Thanks for the “head’s up” !

  3. September 25, 2009 at 5:07 pm

    Hi,

    This method you presented will be the way to handle things in the future, definitely.

    For now, the sure fire way to enable Chrome Frame support in WordPress is via a plugin:
    http://wordpress.org/extend/plugins/google-chrome-frame-for-wordpress/

  4. September 26, 2009 at 12:07 am

    Why install a 10k plugin when one line in header.php will do?

  5. September 26, 2009 at 3:51 am

    Grated, ck. But the plugin also brings other features. Like the ability to prompt the user to install the Chrome Frame add-on.
    Plus, some less savvy people should never be put to manually edit the header of their blog theme. ;)

  6. September 26, 2009 at 5:02 am

    Users should not be nagged, ever.

    Teaching people, especially IE users to click on things that nag them, is VERY dangerous.

    We don’t exist to promote Google. Taking advantage of an existing plugin is fine but I’ll never shill for their product even if it’s free because that implies a responsibility to help the person if it screws up their browser somehow.

    They might never come back to your site if things go wrong.

  7. September 26, 2009 at 5:09 am

    Users are always nagged!
    From the WordPress comment form to Windows update to Apple update to linux update-manager.
    Because they’re lazy, that’s why.

    This is no longer about the plugin or Chrome Frame. Users must be nagged, otherwise they don’t care fast enough.

    That’s why Firefox has an auto-updater that prompts you about, well, updates. Which approach is better? Firefox’s update prompt or Google’s background updater that does its job without asking you anything? I digress.

    I agree that forcing a user to do something is bad, but letting them know of something that might help them out… that’s a one-time nag I can live with.


Leave a Reply




c

Blog Stats

  • 64,715 hits

 

September 2009
S M T W T F S
« Aug    
 12345
6789101112
13141516171819
20212223242526
27282930