문제

I have a desktop app built with TideSDK and java script.

The idea is to use system login to autologin ot the tideSDK app. I have tried following code snippet to get the system login username.

var WinNetwork = new ActiveXObject("WScript.Network");    //option 1 ref http://stackoverflow.com/questions/2968690/get-windows-username-with-javascript
console.log(WinNetwork);

var userName = @HttpContext.Current.User.Identity.Name;   //option 2 ref http://stackoverflow.com/questions/12820172/how-to-get-the-current-login-user-name-in-my-script-file-inside-my-asp-net-mvc

In the option 1 it says ActiveXObject is not available.

In the option 2 it gives a parse error

SyntaxError: Parse error

Invoking masonry    /C:/ProgramData/TideSDK/modules/win32/ui/1.3.1%2Dbeta/ui.js:95

Option 1 may not work on anything other than IE.

What's wrong I am doing with option 2?

Is there any other way to get system user name from TideSDK app?

도움이 되었습니까?

해결책

The TideSDK provides it's own way to solve this.

just use

<script type="text/javascript">
    var username = Ti.Platform.getUsername();
    console.log(username);
</script>

That will give the username of current system login

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top