To provide users with the best browsing experience, Microsoft® Internet Explorer 4.0 introduced offline browsing to the Win32® platform. Internet Explorer 5 extends offline browsing, supporting "smarter" offline Favorites.
This article describes the creation and implementation of smart offline Favorites. Using a combination of Channel Definition Format (CDF) and HTML elements, Web authors can enhance the offline browsing experience for users with Internet Explorer version 5 and later.
Offline browsing allows users to view Web pages from the cache, a local repository of files gathered from the Web, through normal browsing and through the delivery of content subscriptions.
Users can choose to work offline by selecting Work Offline from the File menu in Internet Explorer 4.0 and later. When working offline, the system functions independently, regardless of any network connection, and content is read exclusively from the cache. If the content is not available locally, Internet Explorer asks users if they want to go online to view the content or continue working offline.
Offline browsing is an easy feature for users to discover and use in Internet Explorer 5 and later. Users adding Web pages to Favorites will see a "Make available offline" check box in the Add Favorite dialog box. When users select the box, the Customize command button is enabled. The Offline Favorite Wizard is activated by clicking the Customize button. The wizard enables users to make linked pages available offline, create a synchronization (update) schedule, and enter site-specific user names and passwords.
The following HTML can be included in the HEAD object of a Web page to specify a relationship with the CDF file indicated by the HREF property:
<LINK REL="Offline" HREF="/filename.cdf">
LINK is an HTML element that specifies a relationship with another object. REL is an attribute of LINK that sets or retrieves the specified relationship. For offline favorites, the value of the REL attribute is "Offline."
CDF is an XML vocabulary, or XML-based data format, that can be used to organize a set of related Web documents into a logical hierarchy. CDF enables developers to describe the structure and logically present various structured views of their HTML-based sites. Individual Web pages can be described by a CDF file to specify a hierarchy of associated Web pages.
In general, authoring a CDF file for offline Favorites is similar to developing Active Channel content. The main difference is that you use a subset of CDF elements when developing an offline Favorite; the CHANNEL and ITEM elements are currently supported.ITEMs specified by the author of the CDF file supersede the Offline Favorite Wizard, in which the user can choose whether or not to include one level of linked pages for offline use. In this way, the Web author can assist the offline user by selecting a subset of linked pages, selecting content more than one level deep, or even selecting content that isn't linked.
Note Although the offline Favorite feature of Internet Explorer 5 and later uses a subset of the CDF vocabulary, Internet Explorer ignores the CDF elements it doesn't use. It may not be necessary, therefore, to author separate CDF files for Active Channel sites and offline Favorites.
The "Offline" value for the REL attribute (of the LINK element) is supported by Internet Explorer 5 and later. Earlier versions of Internet Explorer will ignore LINK REL="Offline".
The Microsoft CDF Generator is one of the Web authoring tools available to members of MSDN Online. Members can download it free. The tool's graphical interface is useful for creating initial CDF files. But you can create a CDF file with any text editor.
Offline Favorites save connection charges, navigation and download time, and enable users to take Web content with them wherever they can go with their computers. All of the desired text, graphics, and multimedia files can be placed on users' hard drives for offline browsing. By "synchronizing" their offline favorites, users can quickly and easily update their offline content.
Previously, users had two choices when adding offline Favorites. They could choose to have all of the article's links available offline, or none of them. Authors can now offer users a more meaningful alternative.
By choosing which pages go offline with a given Web page, authors can give users access to an intelligent subset of additional pages, enhancing the experience for users viewing content offline. This is a much more friendly alternative than "all or nothing."
The offline browsing experience can be enhanced for almost any Web page a user might add to offline Favorites. Web pages contain links to other Web pages, and some of the linked pages are more useful than others in offline mode. Going a step further, pages linked to these linked pages might also be useful to the user offline.
Perhaps you are authoring a research article for an educational institution. The article will contain links to the department that sponsored your work and links to online references that supported your research. Perhaps the article will be hosted in a frame containing links to the whole institution. Offline readers of your work might might like to have your references available offline. They might find offline access to your institution's home page less useful.
But if a user precaches all the linked pages one level down, they get all the links, useful or not. Prior to Internet Explorer 5, the only other choice was precaching none of the linked pages, which can also detract from the offline browsing experience.
Consider the reader of this article, for example. A user adding this article to Favorites for offline browsing is likely to be a Web author who has an interest in implementing the technology. This user would find the CDF references useful offline also. The HTML LINK element and the REL attribute are summarized adequately within the article.
A CDF file for this article might look like this:
<?XML VERSION="1.0" ENCODING="windows-1252"?> <CHANNEL HREF="/Workshop/delivery/offline/linkrel.asp" LASTMOD="1998-09-19T22:12" PRECACHE="YES" LEVEL="0"> <ITEM HREF="/Workshop/delivery/cdf/reference/CHANNEL.asp" LASTMOD="1998-09-19T22:12" PRECACHE="YES" LEVEL="0"> </ITEM> <ITEM HREF="/Workshop/delivery/cdf/reference/ITEM.asp" LASTMOD="1998-09-19T22:12" PRECACHE="YES" LEVEL="0"> </ITEM> </CHANNEL>
In the sample above, the CHANNEL element defines the top-level of the hierarchy. Its attributes specify the offline Favorite's URL, the date the page was last modified, and the number of levels deep the browser should site crawl and precache the CHANNEL's content.
The ITEMs nested within the CHANNEL element define the next level in the hierarchy of associated Web pages. Each of the above ITEMs specifies a URL that represents the location of the page, the date the page was last modified, and the number of levels deep the browser should site crawl and precache the ITEM's content.
<LINK REL="Offline" HREF="/FolderName/FileName.cdf">
This line specifies a relationship between the Web page and the CDF file you will create in the next step.
<?XML VERSION="1.0" ENCODING="windows-1252"?> <CHANNEL HREF="/FolderName/WebPage.htm" PRECACHE="YES" LEVEL="1"> </CHANNEL>
<?XML VERSION="1.0" ENCODING="windows-1252"?> <CHANNEL HREF="/FolderName/WebPage.htm" PRECACHE="YES" LEVEL="0"> <ITEM HREF="/FolderName/RelatedPage1.htm"></ITEM> <ITEM HREF="/FolderName/RelatedPage2.htm"></ITEM> </CHANNEL>
Developers should be aware that the URLs of cached pages must exactly match the HREF values of the anchor tags. Whether or not you are authoring content specifically intended for offline use, it is a good practice to be careful authoring anchor tags. If a user takes a page and its links offline (adds an offline Favorite), and an HREF value in an anchor tag isn't identical to the file name of the linked page, the user won't have offline access to the linked page unless he or she knows to enter the correct URL in the address bar.
To ensure that hyperlinks for your smart offline Favorites will work when the user is browsing offline, author the HREF values for ITEMs in your CDF file exactly the same way you authored the hyperlinks on your Web pages. If the hyperlink on your Web page says /FolderName/RelatedPage1.htm, the HREF value for the corresponding ITEM in your CDF file should also say /FolderName/RelatedPage1.htm. Likewise, if the hyperlink on your Web page only says /RelatedPage1.htm, the HREF value of the corresponding ITEM in your CDF file should also only say /RelatedPage1.htm.
The reason for this is that Internet Explorer respects the URL of the page the user is viewing when adding it to offline Favorites.
Web authors can prevent Internet Explorer from crawling the links on any Web page by inserting the following HTML into the HEAD section of the page. This prevents users from making linked pages available offline when they use the Customize option in the Offline Favorite Wizard:
<META NAME="ROBOTS" CONTENT="NOFOLLOW">
To prevent Internet Explorer from crawling all pages on a Web site, a file named Robots.txt should be placed in the root directory of the Web server. This file should contain the following lines:
User-Agent:MSIECrawler Disallow:/path/
In this example, path is the name of the path that Internet Explorer should not site crawl. A path of "/" can be used to exclude all pages on the server. Note that "MSIECrawler" can be replaced with "*" to indicate that all automated crawling robots (including Internet Explorer) should be excluded.
The following lists contain links to topics related to offline Favorites and CDF.
Tutorials