Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
241 views
in Technique[技术] by (71.8m points)

javascript - JavaScript-如何获取当前用户的名称(JavaScript - How to get the name of the current user)

I was wondering how I would get the name of the current user in JavaScript as part of an HTML document.(我想知道如何将JavaScript中的当前用户的名称作为HTML文档的一部分。)

In Java, one would type System.getProperty("user.name");(在Java中,将键入System.getProperty("user.name");)

to achieve this.(为达到这个。) What is the alternative to this in JavaScript?(在JavaScript中有什么替代方法?)   ask by Confiqure translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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在当前HTML文档的上下文中运行,因此除非当前页面位于当前页面中,否则您将无法确定有关当前用户的任何信息,或者您对服务器端脚本进行AJAX调用以获取更多信息。)

JavaScript will not be able to determine your Windows user name.(JavaScript将无法确定您的Windows用户名。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...