0

How can I make "visual studio code" open when a button is pressed on my website?

mrdenizlp
  • 78
  • 14
  • 1
    Maybe this will help: https://stackoverflow.com/questions/3057576/how-to-launch-an-application-from-a-browser – Steve Aug 02 '21 at 17:04
  • @Steve actually yes, you can't launch the application, but when I install visual studio extensions from microsoft (like "Live Share"), after logging in, an option like "Would you like to open visual studio code" appears at the top of the website. How can I do that? – mrdenizlp Aug 02 '21 at 17:08

2 Answers2

1

Set the href of your button to the text vscode: this should bring up dialog in the browser that a website wants to open vscode.

<a href="vscode:">Clicking me will create a prompt to open vscode</a>

enter image description here


If you want to open vscode without user input you can use the window.open method.

In your case:

window.open("vscode:", "_blank")

will create an automatic pop-up to open vscode.

lejlun
  • 4,140
  • 2
  • 15
  • 31
  • i create a test code and i wrote: ` open vscode ` and nothing happened – mrdenizlp Aug 02 '21 at 17:16
  • Did you click the link that appeared? – lejlun Aug 02 '21 at 17:21
  • @mrdenizlp I've made an edit to my post that should hopefully make it more clear. – lejlun Aug 02 '21 at 17:25
  • it just seemed like the page was being refreshed but visual studio code didn't open I'm wondering if the problem is with me – mrdenizlp Aug 02 '21 at 17:25
  • If you already have visual studio opened nothing will happen. @mrdenizlp – lejlun Aug 02 '21 at 17:26
  • I closed the program and tried again. Again nothing happened and in the last code you edited, a new tab with the url `vscode:` opened in the browser but again doesn't work – mrdenizlp Aug 02 '21 at 17:30
  • @mrdenizlp If you create a new tab and type `vscode:` does anything happen, if not try `vscode:extension` – lejlun Aug 02 '21 at 17:33
  • I'm starting to think that the problem is me. I guess it's because I'm using "VS Code Insiders". I'll write again if I can't find the problem by searching a little more. Thanks for everything – mrdenizlp Aug 02 '21 at 17:41
1

<a href="vscode://file/path/to/my_project/readme.md">open readme.md in vscode</a>
Henock
  • 98
  • 11