3

In VSCode, is it possible to open a new pane pointing to an http url? I have a server running locally (on port 8080). I want to open it as a WebView. I couldn't find anything that provides this in the WebView API docs.

The functionality I'm looking for is similar to the snippet, except with the url opening in the VSCode editor iteself.

vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('http://locahost:8080'));
Gama11
  • 31,714
  • 9
  • 78
  • 100
sanchit
  • 2,328
  • 2
  • 18
  • 22
  • 2
    Possible duplicate of [How to open a browser within VSCode just like another editor tab](https://stackoverflow.com/questions/46356759/how-to-open-a-browser-within-vscode-just-like-another-editor-tab) – Matt Bierner Jan 29 '19 at 01:10

1 Answers1

0

You can achieve by using an iframe within webview https://code.visualstudio.com/docs/extensions/webview

 // And set its HTML content
 panel.webview.html = 
`<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Cat Coding</title>
    </head>
    <body>
        <iframe width="100%" height="100%" src='http://locahost:8080'> </iframe>
    </body>
    </html>`;
invinciblejai
  • 1,103
  • 1
  • 8
  • 15