THE SQL Server Blog Spot on the Web

Welcome to - The SQL Server blog spot on the web Sign in | |
in Search

Steve Kass

SQL MVP since 2002 Professor of Mathematics and Computer Science at Drew University

How to convert Books Online ms-help: links to MSDN Library http: links [bookmarklet included]

As you know, Books Online is available in two convenient locations. It's online as part of the MSDN Library, and it's offline as a Document Explorer help collection. Topics are accessible by URIs in each, but the URIs don't match. For example:

A while ago, another MVP said it would be nice for "local" Books Online to have a "find this page on the web" link. Local Books Online is usually faster and more convenient, but for blog, newsgroup, or forum posts, it makes more sense to paste in MSDN Library links, so they're clickable from the reader's browser. Alan Brewer of the SQL Server Documentation Team provided a helpful tip: MSDN will understand the GUID from the local Books Online link and redirect your request.

In other words,  

Books Online Topic: CREATE STATISTICS (Transact-SQL)
Document Explorer URI: ms-help://MS.SQLCC.v10/MS.SQLSVR.v10.en/s10de_6tsql/html/b23e2f6b-076c-4e6d-9281-764bdb616ad2.htm
Alternate MSDN Library URI:

So I wrote this Javascript applet that works from inside local Books Online to put the Alternate MSDN Library URI on the Windows clipboard:

javascript:(function(){window.clipboardData.setData("Text","" + location.pathname.slice(-40,-4) + ".aspx");})(); 

I also found a handy place to install it. I set it as Document Explorer's "Search Page" URL, which you can specify from local Books Online under Tools->Options. There was already a toolbar button in Books Online for Web Browser Search (a globe with binoculars). Now when I click on it, an MSDN Library URL of the Books Online article I'm reading is on my clipboard, ready to paste anywhere. (I don't use Books Online for web browser searches, and I'm guessing neither do you, so nothing is lost by redefining this button.)

Pretty cool, I thought. Until Alan quickly added that MSDN doesn't always understand and correctly redirect the URL-with-GUID. In particular, not for local Books Online pages that describe the managed API. So I did some quick and dirty guess-and-test bookmarklet development, and this is what I ended up with. Based on limited testing, it works on "regular" SQL Server topics as well as managed API ones.

javascript:(function(){var s = document.getElementsByTagName('head').item(0).innerHTML; var p ="AssetID"); s = s.substr(p+16); p ="\""); s = s.slice(0,p); p =":"); if (p>-1) s = s.substr(p+1); window.clipboardData.setData("Text","" + s.toLowerCase() + ".aspx");})(); 

The bookmarklet is a Javascript program, so you could enhance it further to do all kinds of useful things. For example, clicking on the globe could raise a dialog where you pick a language (to replace en-us in my bookmarklet), and copy the language-specific URL to the clipboard.

With luck, this bookmarklet will be useful to a few readers, not to mention do some bookmarklet evangelism.





Published Wednesday, August 05, 2009 12:11 AM by skass



TiborKaraszi said:

Very useful!

Thanks for sharing, Steve. :-)

August 5, 2009 2:19 AM

Scott Whigham said:

Oh wow - that's just fantastic. Thanks for sharing. Has anyone made a Microsoft Connect suggestion regarding adding this type of link into BOL?

August 5, 2009 9:53 AM

AaronBertrand said:

Not to steal Steve's thunder, but I've been meaning to file this for about a week now:

August 5, 2009 10:29 AM

Aaron Bertrand said:

Sorry, I've been trying to keep this to a regular Saturday installment, but it was a beautiful weekend

August 9, 2009 5:04 PM
New Comments to this post are disabled
Privacy Statement