MSDN7 link converter


Online converter[^]

This is a simple conversion tool aimed to make MSDN 7 links be much more easily shared with your peers.

It converts a local ms-help:// link to the actual online http:// link on the MS website MSDN library. Doing so, you don't need to assume anymore they have the locally installed MSDN 7 library too.


1. Using the converter

It's written with javascript. And it has been tested under the following environments :

Just paste your ms-help:// link, and click Convert link. You'll get the http:// link in the output field to copy from.

If you are running Internet Explorer, you are rewarded an additional interactive link to play with.


2. The code for the converter

The conversion is simple enough and uses a regexp[^] flavor.

The ms-help:// protocol uses URIs of the form ms-help://[MS.xxxx/]^+ [subtopic/]^+ url.htm, where MS.xxxx are namespaces. Those namespaces are only navigation helpers within the locally installed MSDN library and are not needed for the online version.

In addition, the online MSDN library is not totally synched with the locally installed MSDN. The online MSDN library still has a strong branch separation between the old MSDN online content (web workshop), and the current content. Whereas the locally installed MSDN library is uniformly categorized. That's the reason why there are special cases to manage during the conversion.

The few awkward regexp rules are as follows :

Code is as follows :

<b style="font-size:9pt;">MSDN7 link converter</b> 
<i style="font-size:9pt;">Stéphane Rodriguez. Dec 14, 2003.</i>
<script language="javascript">
function convertlink()
  var srclink = document.forms["converter"].elements["msdn7link"].value;

  if (srclink.length==0)
    alert("Please provide a ms-help:// link");

  // ms-help URIs are of the form :
  // ms-help://[MS.xxxx/]^+ [subtopic/]^+ url.htm
  // example :
  // ms-help://MS.VSCC/MS.MSDNVS/vbcon/html/vbconMigratingVI60ApplicationsToVS70.htm

  srclink = srclink.replace(/ms-help:\/\//,""); // remove ms-help://
  srclink = srclink.replace(/MS\.[^\/]*\//g,""); // remove all namespaces
  srclink = srclink.replace(/\.htm/,".asp"); // replace .htm URL with .asp

  // manage special cases (these are the out-of-sync branches
  // between the stand-alone doc and the website doc)

  // case 1 : .NET frmwk branch misleading name
  srclink = srclink.replace(/cpguidenf\//,"cpguide/");

  // case 2 : old MSDN web workshop branch
  var nOldStringLen = srclink.length;
  srclink = srclink.replace(/\w*\/workshop\//,"workshop/");

  if (nOldStringLen==srclink.length)
    srclink = "" + srclink;
    srclink = "" + srclink; // old workshop branch

  // display http:// link
  document.forms["converter"].elements["msdnhttplink"].value = srclink;

  // create interactive link
  if (document.all)
    hlink.innerHTML = "<a href='"+srclink+"' target=_blank>Click here[^]</a>";


<form name="converter" onsubmit="javascript:convertlink();return false;">
 <tr><td style="font-size:9pt;" width=80>ms-help link :</td>
     <td><INPUT TYPE="text" NAME="msdn7link" id ="msdn7link" 
 <tr><td style="font-size:9pt;" width=80>ms http link :</td>
     <td><INPUT TYPE="text" NAME="msdnhttplink" size="100"></td>
 <tr><td><input TYPE="submit" value="Convert link"></td>
     <td> </td>

<div id="hlink"></div>


3. History


Stéphane Rodriguez - Nov 29, 2002.