Ian (Fluxtah) Warwick's blog RSS 2.0
# Thursday, October 09, 2008

I am quite impressed with IE8 beta 2, annoying bugs aside. One feature of IE8 that is very useful is accelerators, I decided to give it a shot today to see if I could get one working and its surprisingly easy.

You can create an accelerator by writing an xml document in the OpenService Format Specification for Accelerators and making the file accessible from a website, then creating a button with an onclick handler that calls window.external.AddService(url_to_xml_file).

As a quick test I created an xml file to describe an accelerator for my blog similar to the following.

<?xml version="1.0" encoding="UTF-8"?>
<os:openServiceDescription
    xmlns:os="http://www.microsoft.com/schemas/openservicedescription/1.0">
    <os:homepageUrl>http://www.yoursite.com</os:homepageUrl>
    <os:display>
        <os:name>Blog with your site</os:name>
        <os:icon>http://www.yoursite.com/favicon.ico</os:icon>
        <os:description>Blog on your site easily</os:description>
    </os:display>
    <os:activity category="Blog">
        <os:activityAction context="selection">
            <os:execute action="http://www.yoursite.com/blog/add_entry.aspx" method="get">
                <os:parameter name="title" value="{selection}" type="text" />
            </os:execute>
        </os:activityAction>
    </os:activity>
</os:openServiceDescription>

The most notable tags are described below:-

  • <os:activityAction context="selection">
    The value 'selection' of the context attribute of this tag specifies that this accelerator will be available when the user selects a block of text, there are two other possible options:-

    'document' - makes the accelerator available for the whole document.
    'link' - makes the accelerator available when the user selects a link.

  • <os:execute action="http://www.yoursite.com/blog/add_entry.aspx" method="get">
    The action of the execute tag does the business of redirecting to, or in this case, accelerating to the add entry page of the blog service, we can do this via a http GET or POST as described by the method attribute.

  • <os:parameter name="title" value="{selection}" type="text" />
    You can add a collection of these parameters that will be either sent as GET or POST vars, depending what you set for the method of the execute tag above, {selection} is a placeholder for information that is retrieved from the page that we are accelerating from, there are many possible options here which I will not list as they are available on msdn accelerator docs.

Once this xml document is ready and uploaded all that is needed is a link to it from a html document like the one below.

<html>
    <head><title>My Blog Accelerator</title></head>
    <body>
        <button id="installButton" onclick="window.external.AddService('my_accelerator.xml');">Add My Blog Accelerator</button>
    </body>
</html>

The example above would require the html document to be in the same path as my_accelerator.xml. 

And thats all there is to it, the documentation for developing accelerators can be found on msdn. 

Thursday, October 09, 2008 3:52:00 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] -
Internet Explorer 8
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Ian Warwick
Sign In
Statistics
Total Posts: 33
This Year: 0
This Month: 0
This Week: 0
Comments: 4
Themes
Pick a theme:
All Content © 2012, Ian Warwick
DasBlog theme 'Business' created by Christoph De Baene (delarou)