简体   繁体   English

在 Visual Studio Code 中编码时如何阻止实时服务器自动打开浏览器?

[英]How to stop live-server opening the browser automatically while coding in Visual Studio Code?

I am trying to build a homepage of a website in Kali Linux. So, I installed VS Code and added an extension " Live Server " written by Ritwick Dey.我正在尝试在 Kali Linux 中构建一个网站的主页。因此,我安装了 VS Code 并添加了一个由 Ritwick Dey 编写的扩展“Live Server”。 I made HTML file, then CSS and now JavaScript. When I was writing HTML and CSS files, everything was normal with Live Server.我制作了 HTML 文件,然后是 CSS,现在是 JavaScript。当我写 HTML 和 CSS 文件时,Live Server 一切正常。 But when i started writing JavaScript file, there happened a glitch.但是当我开始编写 JavaScript 文件时,出现了一个小故障。 Every time, when I take rest after writing some text in alert(" ");每次,当我在alert(" "); , the browser automatically opens. , 浏览器自动打开。 I had used only alert("some text");我只用过alert("some text"); in JavaScript file.在 JavaScript 文件中。 After, I made some changes in file by adding some other statements such as document.getElementById("appname").innerHTML="howdy";之后,我通过添加一些其他语句对文件进行了一些更改,例如document.getElementById("appname").innerHTML="howdy"; Other statements do not made any disturbance but when I write alert("some_text");其他语句不会造成任何干扰,但当我写alert("some_text"); , the browser automatically opens. , 浏览器自动打开。

I had enabled Auto Save as "afterDelay" and, while writing this question, I gave "off" value to Auto Save , it stopped automatically opening the browser but when I save the file, it opens the browser.我启用了自动保存为“afterDelay”,并且在写这个问题时,我给自动保存设置了“关闭”值,它停止自动打开浏览器,但是当我保存文件时,它会打开浏览器。

I do not want to let the browser open automatically, when I save the file.当我保存文件时,我不想让浏览器自动打开。 I want to open the browser manually.我想手动打开浏览器。

you can put your alert in a function with javascript, make a timer on onclick button so it works when you want it not when server loads你可以把你的警报放在 function 和 javascript 上,在 onclick 按钮上做一个计时器,这样它就可以在你想要的时候工作,而不是在服务器加载时工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在运行实时服务器的情况下在 Visual Studio Code 中调试 JavaScript - How to Debug JavaScript in Visual Studio Code with live-server Running 关闭和打开应用程序的实时服务器会删除我的本地存储 - closing and opening live-server for an app deletes my local storage 如何在 VSCode chrome live-server 中运行 npm 模块(puppeteer)? - How to run npm module (puppeteer) in a VSCode chrome live-server? 是什么导致npm live-server停止检测文件更改? - What would cause npm live-server to stop detecting file changes? 为什么实时服务器会注入这些 javascript 代码 - why is live-server injecting these javascript codes 使用 npm 安装 live-server 包时出错。 `npm audit` 无助于解决问题 - Getting error while installing live-server package using npm. `npm audit` is not helping to fix the problem 为什么我的实时服务器不能在 visual studio code 中工作? - why doesn't my live server work in visual studio code? 您可以在 Live 服务器扩展 Visual Studio 代码中链接子页面吗 - Can you link subpages in Live server extension Visual studio code 为什么VS code live server打开一个目录而不是在浏览器中运行代码? - Why is VS code live server opening a directory instead of running the code in the browser? Visual Studio代码扩展:如何在拖动鼠标时停止触发onDidChangeTextEditorSelection事件? - Visual Studio Code Extensions : How to stop firing onDidChangeTextEditorSelection events while dragging mouse?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM