Using getBookmark and moveToBookmark
The getBookmark method doesn't do what you might initially think. It doesn't allow you to create a link to an internet shortcut or get one from the user's machine. What it does do is create a "snapshot" of a selection so you can return to it later. The information returned from the getBookmark method is opaque. This means that it is unreadable and doesn't have any context on it's own. It can only be used by the moveToBookmark method to move to the saved selection.
Example:
Select any text on this page and then click here: . This has created a bookmark that has been saved to a variable. Now, select another block of text on the page and then click here: . You now have two bookmarks stored in variables that can be retreived at any time.
An example application of this feature could be a content highlighter for your companies intranet. It would allow your employees to browse articles and highlight information that they found interesting. The bookmarks to this highlighted information could be stored in a database. The next time the user browsed to the page you would use moveToBookmark to "relight" that information.
Problems with getBookmark
The biggest problem with using getBookmark is any change that is made to the HTML on the page may cause unusual behaviour. Any content within a sentence of the content that has been changed will likely cause the moveToBookmark method to either select the incorrect text or not work at all. This is especially troublesome when using these methods with the MSHTML or DEC as the likelihood of the content having changed since you bookmarked it is quite likely.
MSDN Reference: getBookmark
method
MSDN Reference: moveToBookmark
method
Conversation
firstly,thanks for the example,but my problem is that when I saved the variable,and then open another file and then open the first again, error happens,as:movetobookmark in the variable,the method stopped and an error showed to me. What kind of problem is it? Thanks again.
Great stuff ... thanks :)