如何在 JavaScript 中获取当前 Windows 用户的名称 [英] How to get the name of the current Windows user in JavaScript

查看:74
本文介绍了如何在 JavaScript 中获取当前 Windows 用户的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在 JavaScript 中获取当前用户的姓名作为 HTML 文档的一部分.

I was wondering how I would get the name of the current user in JavaScript as part of an HTML document.

在 Java 中,可以输入 System.getProperty("user.name"); 来实现这一点.JavaScript 中的替代方法是什么?

In Java, one would type System.getProperty("user.name"); to achieve this. What is the alternative to this in JavaScript?

推荐答案

JavaScript 在当前 HTML 文档的上下文中运行,因此它无法确定有关当前用户的任何信息,除非它在当前页面中或您对服务器端脚本执行 AJAX 调用以获取更多信息.

JavaScript runs in the context of the current HTML document, so it won't be able to determine anything about a current user unless it's in the current page or you do AJAX calls to a server-side script to get more information.

JavaScript 将无法确定您的 Windows 用户名.

JavaScript will not be able to determine your Windows user name.

这篇关于如何在 JavaScript 中获取当前 Windows 用户的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆