Vous êtes sur la page 1sur 12

Activities:

Windows® Internet Explorer® 8


Beta 1 for Developers

Making the Web Work for You

March 2008

For more information, press only:


Rapid Response Team
Waggener Edstrom Worldwide
(503) 443-7070
rrt@waggeneredstrom.com
The information contained in this document represents the current view of Microsoft Corp. on the issues discussed
as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be
interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any
information presented after the date of publication.

This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR
STATUTORY, AS TO THE INFORMATION IN THIS DOCUMENT.

Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under
copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or
transmitted in any form or by any means (electronic, mechanical, photocopying, recording or otherwise), or for
any purpose, without the express written permission of Microsoft Corp.

Microsoft may have patents, patent applications, trademarks, copyrights or other intellectual property rights
covering subject matter in this document. Except as expressly provided in any written license agreement from
Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights
or other intellectual property.

Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos,
people, places and events depicted herein are fictitious, and no association with any real company, organization,
product, domain name, email address, logo, person, place or event is intended or should be inferred.

© 2008 Microsoft Corp. All rights reserved.

Microsoft, Windows, Windows Vista, Windows Server, ActiveX, Active Directory, Internet Explorer, the Internet Explorer logo, MSN and the
MSN logo are either registered trademarks or trademarks of Microsoft Corp. in the United States and/or other countries.
The names of actual companies and products mentioned herein may be the trademarks of their respective owners.
OVERVIEW

Activities are contextual menu options which quickly access a service from any Web page. Users typically
copy and paste from one Web page to another. Internet Explorer 8 Activities make this common pattern
easier to do.

Activities typically involve two types of scenarios: "look up" of information within a Web page, and
"send" of Web content to a Web application. Consider the example of a user who is interested in a
restaurant and wants to see its location. This is the form of a "look up" Activity, where the user selects
the address and views an in-place view of the map using a favorite map service.

In an example of a "send" Activity, a user reads an interesting article and wants to blog about it. The
user can select a portion of the article and use the blog Activity. This navigates to the user's blog site
with the selection already available in the edit field.

Users can access an Activity by selecting content on the page. For example, users can select an address
on a Web page and the Activity button appears. Alternatively, you can access Activities by bringing up
the context menu. Activities are also available for the current Web page in the Page Command bar and
for links within a page in the context menu for the link.

Activities are services that user can install and manage. Users can install them from the Internet Explorer
8 Service Guide or through any Web site that advertises Activities.

Activities are described using an XML file that provides the interface of how the browser should
communicate with the service through URL templates. Web-based services should take advantage of
the XML-based Activities since they are easier to create, test, and deploy to users.
FEATURE DETAILS

This section covers the creation and deployment of an XML Activity:

1 XML Format: An Activity is specified using an XML format called Open Service
Description.

2 Category: Activities are grouped based on the category to the user. Internet Explorer 8
Beta 1 for Developers ships with a known set of categories. A service can promote a new
category if necessary.

3 HTTP Submission: XML-based Activities are driven off of HTTP GET/POST requests.

4 Preview: An Activity can provide an in-context preview. This is like a miniature Web
page that the user can effortlessly view to get a better idea of what the service has to
offer.

5 Localization: Each Activity XML file represents a locale.

6 Deployment: Activities can be made available from your Web site for users to install.

7 Sample: A cut-and-paste example to get started.

1. OpenService Activity Format


An XML-based Activity is described through an XML format called OpenService Activity. These Activities
function though HTTP requests that are specified as part of the XML. This section covers the different
elements and values of the OpenService Activity Format.

OpenService Activity Format

<?xml version="1.0" encoding="UTF-8"?>


<openServiceDescription
xmlns="http://www.microsoft.com/schemas/openservicedescription/1.0">
<homepageUrl>http://maps.live.com</homepageUrl>
<display>
<name>Map with Live Maps</name>
<icon>http://www.live.com/favicon.ico</icon>
</display>
<activity category="map">
<activityAction context="selection" >
<preview action=" http://maps.live.com/geotager.aspx">
<parameter name="b" value="{selection}" />
<parameter name="clean" value="true" />
<parameter name="w" value="320" />
<parameter name="h" value="240" />
<parameter name="format" value="full" />
</preview>
<execute action=" http://maps.live.com/default.aspx">
<parameter name="where1" value="{selection}" type="text" />
</execute>
</activityAction>
</activity>
</openServiceDescription>

The XML namespace for Activities is:

http://www.microsoft.com/schemas/openservicedescription/1.0

The main components to the format are:

- homepageUrl
- display
- activity

homepageUrl
The homepage URL along with the category is used as the identity of the Activity.

homepageUrl element required The main URL of the Activity where the user can access the
service through browsing. All URLs expressed in this format
must match the domain of the homepageUrl.

display
This is how the Activity is presented to the user.

display element required The container element for the following elements.

name element required The name of the Activity that is displayed to the user. The
convention is to lead with the verb followed by the application.
Example: "Map on Windows Live" or "Define with Encarta."

icon element optional The URL to the 16x16 pixel icon of the Activity.

description element optional A short description of the functionality.

activity
This section describes the functionality of the Activity.

activity element required The container element for the functionality


category attribute required The attribute for the activity element.

Each Activity specifies a category that describes the type of


functionality that it offers. Activities are organized by category
so that users can quickly access the types of operation that they
want. Users select the default Activity for a given category. All
default Activities are presented first in the UI, and all other
activities are listed in the overflow UI.

Please read the section on Category for assigning the right one
for your Activity.

activityAction element required An Activity can act on one or more data types. Each
activityAction specifies the functionality based on a data type.
It contains the preview element and execute element.

context attribute optional An attribute for the activityAction element.

Specifies the data type ("selection", "document", or


"link").Default is "selection".

preview element optional The Activity HTML window that displays when the user has
the Activity selected. Please read the section on Preview for
more details.

execute element required The main functionality when the user invokes the Activity.

method attribute optional An attribute for the preview and execute elements.

The type of HTTP method to use ("get" or "post").The default


is "get".

action attribute required An attribute for the preview and execute elements.

The URI template to use for the HTTP submission.

enctype attribute optional An attribute for the preview and execute elements.

The type of content that is submitted to the server. The default


is "application/x-www-form-urlencoded".

accept-charset attribute optional An attribute for the preview and execute element.

The type of character set that is submitted to the server. The


default is "utf-8".
2. Category
Activities are grouped by type so that users can quickly access the tasks that they are interested in.
Users determine the default Activity for a given category when installing the Activity or through the
management UI.

The following are several categories that Internet Explorer promotes, along with examples of existing
services.

map: Windows Live Map, Google Maps, Yahoo! Maps, Mapquest

blog: Windows Live Spaces, Windows Live Writer, Blogger

define: Encarta, Wikipedia, Dictionary.com

add: Del.icio.us, Reddit, Google Reader

translate: Windows Live Translation, Babelfish, Google Translation

If your Activity doesn't fit a recommended category, you can define your own. The following example
defines the category "share":
<activity category="share">

Your category should be a verb that users can recognize. It also should not tied to a specific brand or
application, so that other Activities of similar functionality can use the category.

3. HTTP Submission
Content that the user selects is "sent" to the Activity through HTTP GET/POST submissions. A service can
obtain properties of the document and the user selection as variables. These variables are expressed in
the Activity XML file as part of the action URL or through form-based parameters.

As part of the HTTP request, cookies can be used to store state and user credentials.

These are the available Activity variables:

 documentDomain
 documentTitle
 documentUrl
 link
 linkDomain
 linkRel
 linkText
 linkType
 selection
A variable is enclosed in brackets, as in {documentUrl}. A variable can be specified as optional by using a
"?" after the variable name; for example, {documentUrl?}. To specify that the value of an optional
variable is empty, use an empty text string.

Inline Parameters: These specify the inputs to a service through the URI template.
<execute method="get"
action="http://example.com/done.aspx?url={documentUrl}&title={documentTitle?}" />

In this example, documentUrl is a required variable and documentTitle is an optional variable. If


the value of documentTitle is empty, an empty string is used. If the value of documentUrl is
empty, the Activity generates an error.

Form-Based Parameters: These specify the inputs to a service through name-value pairs, similar
to HTTP form submissions. This is useful for making HTTP POST requests, or if the HTTP GET
request could be longer than the URL character limit.

The following example is based on the previous one:


<execute method="post" action="http://example.com/done.aspx>
<parameter name="url" value="{documentUrl}" />
<parameter name="title" value="{documentTitle?}" />
</execute>

Use the parameter element to list the name-value pairs.

If a variable is indicated as optional and the value is empty, the value of the optional variable is
an empty string. If a variable is required and the value of the variable is empty, the entire name-
value pair is omitted from the form submission.

You can also use the action attribute and parameter elements to track the usage of your service. You do
this by adding a special parameter with a value that indicates it is from Internet Explorer 8:
<execute method="post" action="http://example.com/done.aspx>
<parameter name="url" value="{documentUrl}" />
<parameter name="source" value="IE8" />
</execute>

4.Preview

An Activity can optionally provide a HTML preview that displays when a user hovers over an Activity.
This can be useful to quickly obtain a map, in-place definition or translation, and even ratings or links to
related content.

The preview window should be used for lightweight interaction. The goal is to send users to your site, so
that they view a full Web page for more information. This can be done by users clicking on the Activity
menu item or through links that you provide within the preview window.
Preview functionality is expressed through the Activity XML within the preview element. During the
hover, Internet Explorer makes an HTTP GET/POST request and displays the resulting HTML within the
HTML preview window.

Size: The preview window resolution is limited to 320 × 240 on a 96 DPI display. All content
outside of this region is cut off. We recommend that you not insert content that would display
controls with scrollbars. The preview functionality is intended to let users quickly view
information that does not involve too much interaction.

Hosted Content: The preview supports JavaScript sandboxed to the domain of the Activity. It
also supports ActiveX controls if the controls are already installed and opted-in by the user for
the given domain. Controls that take focus do not work in this window:

 <select>
 <input type="text">
 <text area>

Navigation within the Preview Window: User can navigate within the preview window through
hyperlinks.

Navigation to a Full Web Page: To send user to a full Web page, set the link to open in a new
window. This can be done in two ways:

 Set the target attribute to be "_blank" as part of the hyperlink. When invoked by the
user, Internet Explorer 8 will open this as a new tab.

<a href="gotosite.html"target="_blank">view full site</A>

 Use the open method and set the input URL to the site that you would like the user to
navigate to.

<FORM>
<INPUT
type="button"
value="view full site"
onClick="window.open('gotosite.html')" />
</FORM>
5. Localization
A single Activity XML file maps to a single locale. If your service supports multiple locales, you will need
to have a separate XML file for each locale. From the Web page that you use to advertise Activities, you
should use a user's locale to display the correct XML file for the user to install.

The value of the category element should be localized. For example, in English the category for an
Activity that supports mapping service is "map" but in Spanish it is "mapa."

English Example

<?xml version="1.0" encoding="UTF-8"?>


<openServiceDescription
xmlns="http://www.microsoft.com/schemas/openservicedescription/1.0">
<homepageUrl>http://maps.live.com</homepageUrl>
<display>
<name>Map with Live Maps</name>
</display>
<activity category="map">

</openServiceDescription>

Spanish Example

<?xml version="1.0" encoding="UTF-8"?>


<openServiceDescription
xmlns="http://www.microsoft.com/schemas/openservicedescription/1.0">
<homepageUrl>http://maps.live.com</homepageUrl>
<display>
<name>Mapa con Live Maps</name>
</display>
<activity category="mapa">

</openServiceDescription>

A user can have Activities from multiple locales installed, and all of them are displayed.

6. Deployment
You can also promote Activities from your own Web page. Internet Explorer 8 Beta 1 for Developers
handles the installation of an OpenService Activity file through a new browser API that is accessible by
Web pages.

The first step is to have the OpenService Activity XML file published on a server that your users can
access. The next step is to add an "Install" button from a Web page that your users visit often. You can
check to see if a user currently has your Activity installed:

window.external.IsServiceInstalled("http://maps.live.com/GetMap.xml", "map");
For the check to succeed, the domain of the Web page must match the domain of the URLs specified in
the OpenService Activity XML file. If the check fails, the Web page displays the "Install" button:
window.external.AddService("http://maps.live.com/GetMap.xml");

Internet Explorer 8 also promotes popular Activities through the Service Guide Web page. Please work
with your Internet Explorer 8 contact to see if your Activity meets the requirements to be on this Web
page.

7. Sample
This is a simple sample that shows map Activity that you can host on a Web site.

Activity XML File: Copy the following sample code to a text editor and save it as GetMap.xml. This code
describes the functionality of the Activity, as specified in the OpenService Activity Format section.

<?xml version="1.0" encoding="UTF-8"?>


<openServiceDescription
xmlns="http://www.microsoft.com/schemas/openservicedescription/1.0">
<homepageUrl>http://maps.live.com</homepageUrl>
<display>
<name>Map with Live Maps</name>
<icon> http://www.live.com/favicon.ico</icon>
</display>
<activity category="map">
<activityAction context="selection" >
<preview action=" http://maps.live.com/geotager.aspx">
<parameter name="b" value="{selection}" />
<parameter name="clean" value="true" />
<parameter name="w" value="320" />
<parameter name="h" value="240" />
<parameter name="format" value="full" />
</preview>
<execute action=" http://maps.live.com/default.aspx">
<parameter name="where1" value="{selection}" type="text" />
</execute>
</activityAction>
</activity>
</openServiceDescription>

Hosting the Install Button: To advertise the Activity, add this code snippet to your Web site:

<button onclick="window.external.addService('<path> /GetMap.xml')">Add Map


Activity</button>

To test

1. Install the Activity by clicking on the "Install" button on your Web site. This launches the
installation dialog.
2. Select the Make this my default provider checkbox. This sets the Activity to appear in the top
listing for Activities.
3. Go to a site that contains a street address.
4. Select the address and click on the button that appears next the mouse cursor. (Alternatively,
you can right-click to get the context menu.)
5. Hover over the "Map with Live Maps" Activity. This displays the preview of the map Activity.
6. Click on the "Map with Live Maps" Activity. This navigates to the map Web site in a new tab.

8. Known Issues
 The Activities button does not appear if the Web page is in IE8 Standards mode. Users need
to access the selection Activities by bringing up the context menu.

Vous aimerez peut-être aussi