LESSON 6: Using a custom button to install a Web Slice
LESSON 6: Using a custom button to install a Web Slice
This tutorial explains how to create a customized user experience for your site.
If you have made a big investment in creating Web Slices for your Web site, you might want to advertise them more prominently. Instead of relying on the user to mouse over the content section, you can to add a button or link to your Web site to allow the user to install the Web Slice directly.
- window.external.AddToFavoritesBar( string URL, string Title, string Type )
- URL — The full URL to your page, including the hslice container id as a named anchor (fragment)
- Title — A temporary title for the Web Slice
- Type — Use "slice" to indicate that the item is a Web Slice
Example:
The code below creates a button that adds the ticket auction Web Slice to the Favorites bar
<!-- Add button anywhere inside the right column container -->
<input type="button" value="Add Ticket Auction Web Slice" class="addButton"
onclick='window.external.AddToFavoritesBar(
"https://localhost/webslice/webslice.html#auction",
"Developers, Developers, Developers", "slice");' />
Exercise #6:
Add a button or a link that installs one of the Web Slices on your Web site.
A few things to remember:
- The URL parameter must contain the full URL to your page, and include the hslice id.
- The Title parameter is used only until the Web Slice is downloaded for the first time, then the real title of the Web Slice is used.
Quick Review
- You can invoke the Subscribe to a Web Slice dialog with window.external.AddToFavoritesBar( URL, Title, slice ).
Check your work against the completed version of the sample page in Source Listing #6.
More Lessons
Go back to LESSON 5: Getting Web Slice content from an RSS feed source