使用 Javascript 读取环境变量

Reading environment variables with Javascript(使用 Javascript 读取环境变量)
本文介绍了使用 Javascript 读取环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我需要从客户端操作系统的环境变量中读取系统时间.我在 Stackoverflow 上搜索,发现这是不可能的.但是,这些答案来自 2010 年,我想问一下自那以后是否有任何变化.

I need to read the system time from the environment variables on the client's OS. I searched on Stackoverflow and found that this isn't possible. However, those answers were from 2010 and I want to ask if anything has changed since.

是否有可能使用某种框架?还是 Javascript 仍处于沙盒状态并与操作系统断开连接?

Is it possible with some kind of framework? or Javascript is still sandboxed and cut off from OS?

推荐答案

szpic,如果 Javascript 没有从操作系统沙箱化,任何愚蠢的犯罪分子都可能进入您的计算机并控制.允许环境变量的级别太低了,永远不允许.

szpic, if Javascript were not sandboxed from the OS, any half-witted criminal could get onto your computer and take control. Allowing environmental variables is way too low level to ever be allowed.

看看你所有的环境变量,问问自己这个星球上的每个人是否都应该有权访问关于你计算机的所有数据.

Take a look at all of your environmental variables and ask yourself if everyone on the planet should have access to all that data about your computer.

如果您想使用 Javascript 执行此操作,则必须使用特殊的网络浏览器,例如 node-webkit.不过,它不会在任何普通的网络浏览器上运行,所以不要期望超过 0.0001% 的人会期望运行您的页面.

If you want to do this with Javascript, you'll have to use a special web browser, such as node-webkit. It isn't going to run on any normal web browser, though, so don't expect more than 0.0001% of the population to expect to run your page.

我不知道你的预期用途,但是一个技巧,就是加入一个环境变量,就是为你的 web 应用程序创建一个快捷方式,并将其作为 URL 参数包含在其中(至少在 Winblows 上).

I don't know your intended use, but one trick, to throw in an environmental variable, is to make a shortcut to your web application, and include it in there as a URL parameter (at least on Winblows).

http://myapp.com?computername=%COMPUTERNAME%

这篇关于使用 Javascript 读取环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

SCRIPT5: Access is denied in IE9 on xmlhttprequest(SCRIPT5:在 IE9 中对 xmlhttprequest 的访问被拒绝)
XMLHttpRequest module not defined/found(XMLHttpRequest 模块未定义/未找到)
Show a progress bar for downloading files using XHR2/AJAX(显示使用 XHR2/AJAX 下载文件的进度条)
How can I open a JSON file in JavaScript without jQuery?(如何在没有 jQuery 的情况下在 JavaScript 中打开 JSON 文件?)
quot;Origin null is not allowed by Access-Control-Allow-Originquot; in Chrome. Why?(“Access-Control-Allow-Origin 不允许 Origin null在铬.为什么?)
How to get response url in XMLHttpRequest?(如何在 XMLHttpRequest 中获取响应 url?)