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

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

问题描述



在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屋!

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