title: VSCode: How to enable links in a webpage in the Webview
body: <p><code>vscode.previewHtml</code> got deprecatd in favour of Webview.
  I updated my <a href="https://github.com/Denis-net/vscode-ahk-manager" rel="nofollow noreferrer">ahk extension for vscode</a> using this new API.
  With <code>hh.exe -decompile Docs AutoHotkey.chm</code> I got a local website version of the main AutoHotkey site.
  I wanted to show in the second column a contextual docs so you can read about it while coding. So I did.
  I successfully managed to load the page with the stylesheet, 
  but the links don't work : I stay always on the same page.</p>
  
  <p>Even if I can alter theire href I'm not able to go to another page.
  Althought you can read in tooltip the href value, every time you click on a link nothing happens.
  The Docs folder is stored inside the extension path, so the <code>localResourceRoots</code> should be fine.</p>
  
  <p>A strange thing that i noted is that even with <code>enableScripts</code> is set to true, it seems that not all the js code is executed, because on the AutoHotkey webSite, in the .chm and in every .html files opened with FF I can see the sidebar, but not in the WebView page.</p>
  
  <p>This is the code for creating the WebView:</p>
  
  <pre><code>
   this.docsPanel = vscode.window.createWebviewPanel('ahk-offline-docs', 'Documentation', { viewColumn: vscode.ViewColumn.Two, preserveFocus: true }, {
                  enableScripts: true,
                  enableFindWidget: true,
                  enableCommandUris: true,
                  localResourceRoots: [vscode.Uri.file(path.join(this.docsDirectoryPath, 'docs//')).with({ scheme: 'vscode-resource' })]
              });
              this.docsPanel.onDidDispose((e) =&gt; {
                  this.isDocsPanelDisposed = true;
              });
  </code></pre>
  
  <p>And this is the code that loads the page into the WebView:</p>
  
  <pre><code>
  let url = vscode.Uri.file(path.join(this.docsDirectoryPath, 'docs/')).with({ scheme: 'vscode-resource' });
                      const dom = new JSDOM(data, { runScripts: "dangerously" });
                      const aTags = dom.window.document.getElementsByTagName('a');
                      const len = aTags.length;
                      const basePath = url.toString();
                      for (let i = 0; i &lt; len; i++) {
                          const a = aTags[i];
                          if (!a.href.includes('about:blank')) {
                              const commentCommandUri = vscode.Uri.parse(`command:ahk.spy`);
                              a.href = basePath + a.href;
                              // a.removeAttribute('href');
                              // a.setAttribute('onclick', '{command:ahk.spy}');
                          }
                      }
                      let ser = dom.serialize();
                      this.docsPanel.webview.html = /*data/*ser*/ser.toString().replace('&lt;head&gt;', `&lt;head&gt;\n&lt;base href="${url.toString()}/"&gt;`);
  
  </code></pre>
  
  <p>An alternative idea was to launch vscode.commands from the page (because of <code>enableCommandUris</code>) but I didn't get how to do this kind of operation.</p>
  
  <p>If you need/want to reproduce this issue you just have to clone the repo, going into the <code>improving-offline-docs</code> branch and open the file <code>offline-docs-manager.ts</code>, the method is <code>openTheDocsPanel()</code></p>
  
  <p>Is there a way to switch the current page using links ?
  Should I develop a postMessage system ?
  or I missed a settings somewhere ?
  or is there an even better way for doing it ?</p>
  
  <p>Thanks in advance !</p>