I have tried to get the user information by id. Its alerting fine. But I have to print the user information in the html page.
Source:
<html>
<head>
</head>
<body>
<a onclick="GetUserName();" id="user">aaaa</a>
<script language="javascript">
function GetUserName()
{
var wshell = new ActiveXObject("WScript.Shell");
alert(wshell.ExpandEnvironmentStrings("%USERNAME%, %ComputerName%, %USERDOMAIN%"));
}
</script>
</body>
</html>
Output Should be:
<div id="user">User Information: <span id="userinfo"></span></div>
User Information: "user name, computer name, user domain"
How can i print the information in div or others?
You can use innerHTML
property, it sets or returns the HTML content (inner HTML) of an element.
HTML:
<div id="user">User Information: <span id="userinfo"></span></div>
Javascript:
document.getElementById("userinfo").innerHTML = wshell.ExpandEnvironmentStrings("%USERNAME%, %ComputerName%, %USERDOMAIN%")
just change the inner HTML of the span. Put below statement in place of alert.
document.getElementById("userinfo").innerHTML = wshell.ExpandEnvironmentStrings("%USERNAME%, %ComputerName%, %USERDOMAIN%");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.