MSDN Magazine - March 2009 - (Page 51) a link), Blog (to blog on a remote service), Define (to look for definition), Map (to look for map) and Translate (to translate the selected text). You can also define your own categories. The suggested rules for category definitions are that they should be a verb and generic enough to let other accelerator developers use the same category. Now is the time to define our activitiyActions inside our activity tags. Here you can see one activityAction with a context value of selection: Figure 5 Live Maps Accelerator Provides Instant Location Search Translate it with Contoso http://www.contoso.com/favicon.ico The main properties of an Accelerator are the homepageUrl, display, and activity tags. The homepageUrl is the URL of the service you are providing. All the URLs used in other tags and settings should use the same domain as the homepageUrl. The display tag sets the visual aspects of an accelerator’s command button on the Internet Explorer right-click menu. When the user right-clicks on the page, the accelerator will be revealed by its name and icon. The activity element defines the service that the accelerator provides. In this example, the accelerator will provide a translation activity. You can control how Internet Explorer groups your accelerator on the context menu by using different categories like Add (to add Figure 6 Keyword Options Name documentDomain documentTitle documentUrl link linkDomain linkRel linkText selection msdnmagazine.com Description The domain address of the current page. The title of the current page. The full URL of the current page. If the user clicked a link, this provides the full address of the link. If the user clicked a link, this provides the domain address of the link. If the user clicked a link, this provides the rel property of the link. If the user clicked a link, this provides the text of the link. The selected text on the current page. The context attribute is the key component of an activityAction. The context defines when this action will be available. If the accelerator doesn’t provide an action suitable for the current context, it will not be visible on the accelerator’s menu in Internet Explorer. The current context choices are selection and link. If the context is selection, the user needs to select text and go to the accelerators menu in order to use your accelerator. If the context is link, the user should right-click on a hyperlink to start the action. In each activityAction you can have an execute and a preview definition. Execute is launched when the user clicks the accelerator command from the accelerators menu. Preview action is launched when the user hovers the mouse over the accelerator command on the menu. Both the Preview and Execute tags can have an action URL and a method. You can use GET or POST as methods of data transfer. Parameters are defined for each action as name/value pairs. The values come automatically from keywords in brackets. For instance, {selection} means that the text selected by the user will be the value of the associated parameter. A list of possible value keywords is shown in Figure 6. The preview window works like an IFrame, which means that you can use any kind of interaction inside the preview window. It is more appropriate to design a specific interface and distinguish the preview and execute action URLs. The final OpenService Description file for the example is shown in Figure 7. Now it’s time to let the visitor of our Web site install this accelerator to her PCs. Here is the script needed to install the accelerator: March 2009 51 http://www.msdnmagazine.com
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.