| IE: Browser Bar Details | |
| OCLC Online Computer Library Center, Inc. | |
| Andrew Houghton | |
| Andrew Houghton | |
| urn:uuid:B039797C-E718-477C-A2A4-7D5C948935F2 | |
| 2005-05-25 | |
| 25 May 2005 19:20 -04:00 | |
| 31 May 2005 14:15 -04:00 | |
| 25 May 2005 19:10 -04:00 | |
| 2005 | |
| 1.0.1 | |
| application/xhtml+xml | |
| en-US | |
| InteractiveResource | |
| Publicly accessible | |
|
|
|
band objects
browser bar
browser extension
explorer bar
Internet Explorer
|
|
|
|
| http://www.w3.org/TR/2002/REC-xhtml1-20020801/ | |
| http://www.w3.org/TR/1999/REC-CSS1-19990111 | |
| http://www.w3.org/TR/2004/REC-xml-20040204/ | |
| http://www.w3.org/TR/1999/REC-xml-names-19990114/ | |
| http://staff.oclc.org/~houghtoa/repository/articles/BCCCD5D0-FEAF-4674-BD03-1ACA49308BCA | |
| http://staff.oclc.org/~houghtoa/repository/articles/IEBrowserBarDetails.1.0.1/ | |
| http://staff.oclc.org/~houghtoa/repository/articles/IEBrowserBarDetails/ | |
| © Copyright 2005 OCLC Online Computer Library Center, Inc. All rights reserved. |
A question was sent to the CODE4LIB listserv by Eric Lease Morgan, from the University of Notre Dame Library, asking how someone goes about creating browser toolbars. This article describes how to launch Internet Explorer (IE) browser bars with content generated by dynamic HTML (DHTML). There are several techniques that can be employed to launch an IE browser bar. The browser bar can be launched from an HTML anchor element that targets IE's built-in search explorer bar, from an IE favorite, or integrated into IE using the Windows registry. Each of these techniques are explored throughout the article using a common example.
The HTML anchor technique works by targeting IE's built-in search explorer bar. An HTML anchor element is created in a Web document that includes a target attribute containing the value _search. The href attribute of the HTML anchor element contains the URL of the content to display in IE's built-in search explorer bar. When the link in the Web document is clicked, IE will open the search explorer bar with the contents of your document. See reference [1] to learn more about IE's HTML anchor element. The following is an example of what an HTML anchor element would look like:
<a target='_search' href='http://example.org/search.htm'>
You can launch a demonstration that will open IE's built-in search explorer bar with a sample search form. This demonstration was tested in IE v6.0.2800.1106, but should also work in version 5.X. Interestingly, this technique also works with Mozilla's Firefox v1.0.4 browser.
After you have launched the browser bar, click the X at the top right of the browser bar to close it. Go to IE's menu and select the menu choice. The default search explorer bar will open with Microsoft's content. Using this technique means that the end-user must always navigate to the Web document that contains the link so they can launch the browser bar.
You can make the browser bar a more integral part of IE by using a favorite. The end-user of the browser bar can create the favorite using several different methods in IE such as, using the menu choice, using the mouse context menu, or clicking an HTML anchor element in a Web document. The IE favorite technique is more complex than the HTML anchor technique, previously described, since it requires the use of a JavaScript URL. The JavaScript URL will mimic the HTML anchor technique by using the open method of the window object. The open method of the window object takes a URL to a Web document and a target location. We will use a target location with the value _search, just as we did in the HTML anchor technique. See reference [2] to learn more about IE's window.open method. The following is an example of what a JavaScript URL would look like:
javascript:void(window.open("http://example.org/search.htm","_search"))
When the end-user creates a favorite using IE's menu choice, they will need to enter a complex JavaScript URL, like the one above. Having the end-user manually re-create a JavaScript URL is problematic and I would not recommend using this method, unless the instructions involved cutting and pasting the URL from the text of a Web document. For example you could cut and paste the above JavaScript URL to manually create an IE favorite. A better alternative would be to create an HTML anchor element in a Web document where the end-user could use IE's mouse context menu.
Using IE's mouse context menu is similar to the HTML anchor technique described above. You might ask: why not just use IE's mouse context menu on the link in the HTML anchor technique? There is a subtle difference between using this method and the HTML anchor technique. In the HTML anchor technique we used the target attribute of the HTML anchor element. When you use IE's mouse context menu, it does not maintain the target attribute of the HTML anchor element. Since this method uses a JavaScript URL with the window.open method, the target is maintained since it is part of the method invocation. The following is an example of what an HTML anchor element would look like using the previous JavaScript URL:
<a href='javascript:void(window.open("http://example.org/search.htm","_search"))'>
To create the IE favorite, using this method, you would right click on the link and select the menu choice. You will receive an IE scripting security alert since the href attribute contains a JavaScript URL. Clicking Yes, to continue, will add the URL to your favorites. When you launch the favorite from IE's menu, the favorite will automatically launch IE's search browser bar with a sample search form.
It is important to note that you must use an absolute URL in the open method of the window object. An absolute URL is needed since the end-user of the browser bar will have saved the URL to their local computer, which needs to communicate with the Web server displaying the content in the browser bar. Another interesting point is that you can also launch the browser bar by clicking on the link, just as we did with the HTML anchor technique. Unfortunately, this technique doesn't work in Mozilla's Firefox v1.0.4 browser even though they implemented the _search target for the HTML anchor tag. It appears that they forgot to implement the _search target for the window.open object, otherwise there would be a simple cross browser solution.
With a simple change to the prior HTML anchor element we can automate adding the browser bar link to the end-user's favorites. This can be accomplished by using the AddFavorite method of the window.external object. The AddFavorite method of the window.external object takes a URL that will be used for the favorite and optionally the title to name the favorite. See reference [3] to learn more about IE's window.external.AddFavorite method. The change to the JavaScript URL has a minor complication due to nested double quotes that will need to be quoted so the URL works correctly. The following is an example of what the new HTML anchor element would look like:
<a href= ' javascript:window.external.AddFavorite ( "javascript:void(window.open(\"http://example.org/search.htm\",\"_search\"))", "IE Browser Bar Sample" ) ' >
You can launch a demonstration that automates the process of adding an IE favorite which will open IE's built-in search explorer bar with a sample search form. This demonstration was tested in IE v6.0.2800.1106, but should also work in version 5.X.
The Windows registry technique allows the browser bar to be integrated directly into IE's menu. Initially, the end-user will run a Windows registry script that will install the appropriate entries into their registry. After the Windows registry script is run, the end-user can launch the browser bar by selecting the appropriate browser bar menu choice from IE's menu. This technique requires the end-user to manually run a Windows registry script, which can be problematic in corporate environments where computers have been locked down. It is possible to create a standard Windows installer package that would install the appropriate Windows registry entries and provide the ability to uninstall the changes by using the standard from the Windows , however creating the installer package is currently beyond the scope of this document.
Below are Windows registry scripts that will permanently install or uninstall the browser bar as an alternative to using the IE favorite technique. After you run the install registry script you will need to close IE and reopen it, otherwise the new menu selection will not show up under IE's menu. When you reopen IE go to the menu. You will notice that there is a new menu choice for . Select the menu choice and IE will open the browser bar with a sample search form.
For your convenience, you can download the Windows registry scripts by clicking on the names of the scripts. Alternately, you can copy the install or uninstall script to the Windows clipboard and place it into a text file that has a name ending in the .reg extension. To run the Windows registry script, right click on the text file you downloaded or created and select the menu choice.
REGEDIT4 [HKEY_CLASSES_ROOT\CLSID\{4294FBB6-0330-615C-4D54-57696C4A6F6E}] @="IE Browser Bar Sample" [HKEY_CLASSES_ROOT\CLSID\{4294FBB6-0330-615C-4D54-57696C4A6F6E}\Implemented Categories] [HKEY_CLASSES_ROOT\CLSID\{4294FBB6-0330-615C-4D54-57696C4A6F6E}\Implemented Categories\{00021493-0000-0000-C000-000000000046}] [HKEY_CLASSES_ROOT\CLSID\{4294FBB6-0330-615C-4D54-57696C4A6F6E}\InProcServer32] @="Shdocvw.dll" "ThreadingModel"="Apartment" [HKEY_CLASSES_ROOT\CLSID\{4294FBB6-0330-615C-4D54-57696C4A6F6E}\Instance] "CLSID"="{4D5C8C2A-D075-11d0-B416-00C04FB90376}" [HKEY_CLASSES_ROOT\CLSID\{4294FBB6-0330-615C-4D54-57696C4A6F6E}\Instance\InitPropertyBag] "URL"="http://example.org/search.htm" [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Explorer Bars\{4294FBB6-0330-615C-4D54-57696C4A6F6E}] "BarSize"=hex:C8,00,00,00,00,00,00,00
REGEDIT4 [-HKEY_CLASSES_ROOT\CLSID\{4294FBB6-0330-615C-4D54-57696C4A6F6E}] [-HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Explorer Bars\{4294FBB6-0330-615C-4D54-57696C4A6F6E}]
You can use the above registration scripts as a template for your own browser bar. However, you will need to change the text marked in red. It is important to note that each browser bar is stored in the Windows registry under a globally unique identifier key, known as a GUID. You must generate a new GUID for each browser bar you develop. This means that you will need to replace the occurrences of the GUID {4294FBB6-0330-615C-4D54-57696C4A6F6E} in the Windows registry scripts with the GUID generated for the browser bar you are developing. There are many utilities available for generating GUID's, but the following Windows command script will create a VB.NET console application that can be used to generate a GUID.
@setlocal
@set ScriptDir=%~dp0
@set ScriptFile=%~nx0
@set ScriptName=%~n0
@set exeFile=%ScriptDir%%ScriptName%.exe
@set vbFile=%ScriptDir%%ScriptName%.vb
@set v10=%windir%\Microsoft.NET\Framework\v1.0.3705\vbc.exe
@set v11=%windir%\Microsoft.NET\Framework\v1.1.4322\vbc.exe
@set vbc=
@for %%f in ("%v10%" "%v11%") do @set vbc=%%~f
@if "%vbc%" == "" @goto :NotFound
@del /F /Q "%vbFile%" 2>nul:
@echo Module guid >> "%vbFile%"
@echo Sub Main() >> "%vbFile%"
@echo System.Console.WriteLine("{{{0}}}",System.Guid.NewGuid.ToString.ToUpper) >> "%vbFile%"
@echo End Sub >> "%vbFile%"
@echo End Module >> "%vbFile%"
@"%vbc%" "%vbFile%" "/out:%exeFile%"
@goto :End
:NotFound
@echo Cannot find the VB.NET compiler.
@goto :End
:End
@endlocal
For your convenience, you can download a pre-compiled .NET executable that is ready to run. To generate a new GUID just run the executable from a Windows command prompt. The GUID will appear in the command prompt window where you can copy and paste it into any application. It is important to note that you must have the .NET Framework runtime installed to execute the pre-compiled application. If you are unsure whether the .NET Framework runtime is installed you can check the list of applications generated by under the Windows . You can download the .NET Framework runtime from Microsoft's Web site.
Alternately, you can download or copy the above Windows command script to the Windows clipboard and place it into a text file that has a name ending in the .cmd extension. It is important to note that you must have the .NET Framework SDK, either version 1.0 or 1.1, installed in the default directory on your computer. If you are unsure whether the .NET Framework SDK is installed you can check the list of applications generated by under the Windows . You can download the .NET Framework SDK from Microsoft's Web site.
Should you be unable to run the pre-compiled application or be able to re-create the application from the Windows command script, you can download a Microsoft Access database that will allow you to keep track of the GUID's you create. The Access database contains one table named GuidTable and it contains two columns. The first column is named GUID and the contents will be automatically generated by Access. The second column is named Comment and it indicates the scope of the GUID's usage, e.g., I created this GUID for browser bar X. After you have entered a comment you can copy the GUID in the first column to the Windows clipboard where you can paste it into any application.