JavaScript - 如何获取当前用户的名称 [英] JavaScript - How to get the name of the current user
问题描述
在Java中,我们可以输入 System.getProperty(user.name);
来实现这一点。 JavaScript中的替代方法是什么?
JavaScript在当前HTML文档的上下文中运行,所以它不会能够确定关于当前用户的任何信息,除非它在当前页面中,或者您可以通过AJAX调用服务器端脚本来获取更多信息。
JavaScript不会是能够确定你的Windows用户名。
I was wondering how I would get the name of the current user in JavaScript as part of an HTML document.
In Java, one would type System.getProperty("user.name");
to achieve this. What is the alternative to this in JavaScript?
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 will not be able to determine your Windows user name.
这篇关于JavaScript - 如何获取当前用户的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!