Google Toolbar tests

last modified 2004-12-27 by jon

What are they?

I've compiled a few simple tests for detecting the Google Toolbar and certain configurations thereof. Your results should vary depending on whether or not you have the toolbar installed on your browser. Check out the accompanying code to see how it's done or just take a peek at the page source.

Questions? Corrections? Suggestions? Email me. Feel free to use these scripts throughout your site with or without modification or acknowledgement, although a link to me is always appreciated. Email me if you would like permission to reproduce this article.

Is the toolbar installed on this machine?

The Google Toolbar was not detected.

This test is like www.banbots.com's but simpler. We create a hidden toolbar object, and if it initializes properly, we know that the toolbar is installed. We also check "window.attachEvent" to exclude non-IE browsers from the test.

/* this code goes in the document head */
<object id="googleBar"
    classid="clsid:00EF2092-6AC5-47c0-BD25-CF2D5D657FEB"
    style="display: none;"></object>


/* this code goes in the body */
<script type="text/javascript"><!--
  if(window.attachEvent && document.googleBar
      && typeof(googleBar.Search) != "undefined"){
    /* the toolbar was detected.
     * insert your code here
     */
  }//-->
</script>

Is AutoFill turned on?

AutoFill is not enabled and/or the toolbar is not installed.

This test is an extremely simple one is essentially a modification of the code in my article on disabling yellow input fields. It creates a hidden form, and if the color of the input field is somehow modified, we know that AutoFill is enabled. This test will coexist peacefully with your other scripts and stylesheets. Opera is excluded from this test via "!document.opera" and other non-IE browsers via "window.attachEvent".

/* this code goes in the document head */
<script type="text/javascript"><!--
  if(window.attachEvent && !document.opera)
    document.all['Email'].attachEvent("onpropertychange",detectAutoFill);

  function detectAutoFill(){
    if(event.srcElement.style.backgroundColor != "#ffffff"){
      /* autofill was detected.
       * insert your code here
       */
    }
  }//-->
</script>


/* this code goes in the body */
<form style="display: none;"  action="google_tests.html" id="googleForm">
  <input style="background-color: #ffffff;" name="Email" />
</form>

Is the toolbar turned on?

Coming soon... Any suggestions or insights on detecting this are appreciated.

Compatibility

  • IE 5.0+ (Windows)

Related Pages