ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Retrieve Device and Login details of User in AngularJS<p>&nbsp;</p> <pre class="brush: js">var n = navigator; Agent = n.userAgent; browserName = n.appName; appVersion = n.appVersion.substr(0, n.appVersion.indexOf(&#39; &#39;)); fullVersion = &#39;&#39; + parseFloat(n.appVersion); platform = n.platform; cookie = n.cookieEnabled; BrMajorVersion = parseInt(n.appVersion, 10); OSname = &#39;unknownOS&#39;; width = (screen.width) ? screen.width : &#39;&#39;; height = (screen.height) ? screen.height : &#39;&#39;; screensize = &#39;&#39;; screensize += &#39;&#39; + width + &#34; x &#34; + height; var mobile = { Android: function () { return Agent.match(/Android/i); }, BlackBerry: function () { return Agent.match(/BlackBerry/i); }, iOS: function () { return Agent.match(/iPhone|iPad|iPod/i); }, Opera: function () { return Agent.match(/Opera Mini/i); }, Windows: function () { return Agent.match(/IEMobile/i); }, any: function () { return (mobile.Android() || mobile.BlackBerry() || mobile.iOS() || mobile.Opera() || mobile.Windows()); } }; // In Chrome if ((objOffsetVersion = Agent.indexOf(&#34;Chrome&#34;)) != -1) { browserName = &#34;Chrome&#34;; fullVersion = Agent.substring(objOffsetVersion + 7); } // In Microsoft internet explorer else if ((objOffsetVersion = Agent.indexOf(&#34;MSIE&#34;)) != -1) { browserName = &#34;Microsoft Internet Explorer&#34;; fullVersion = Agent.substring(objOffsetVersion + 5); } // In Firefox else if ((objOffsetVersion = Agent.indexOf(&#34;Firefox&#34;)) != -1) { browserName = &#34;Firefox&#34;; } // In Safari else if ((objOffsetVersion = Agent.indexOf(&#34;Safari&#34;)) != -1) { browserName = &#34;Safari&#34;; fullVersion = Agent.substring(objOffsetVersion + 7); if ((objOffsetVersion = Agent.indexOf(&#34;Version&#34;)) != -1) fullVersion = Agent.substring(objOffsetVersion + 8); } // For other browser &#34;name/version&#34; is at the end of userAgent else if ((OffsetName = Agent.lastIndexOf(&#39; &#39;) + 1) &lt; (objOffsetVersion = Agent.lastIndexOf(&#39;/&#39;))) { browserName = Agent.substring(OffsetName, objOffsetVersion); fullVersion = Agent.substring(objOffsetVersion + 1); if (browserName.toLowerCase() == browserName.toUpperCase()) { browserName = navigator.appName; } } // trimming the fullVersion string at semicolon/space if present if ((ix = fullVersion.indexOf(&#34;;&#34;)) != -1) fullVersion = fullVersion.substring(0, ix); if ((ix = fullVersion.indexOf(&#34; &#34;)) != -1) fullVersion = fullVersion.substring(0, ix); BrMajorVersion = parseInt(&#39;&#39; + fullVersion, 10); if (isNaN(BrMajorVersion)) { fullVersion = &#39;&#39; + parseFloat(navigator.appVersion); BrMajorVersion = parseInt(navigator.appVersion, 10); } //OS if (appVersion.indexOf(&#34;Win&#34;) != -1) { OSname = &#39;windowsOS&#39;; } if (appVersion.indexOf(&#34;Mac&#34;) != -1) { OSname = &#39;macOS&#39;; } if (appVersion.indexOf(&#34;X11&#34;) != -1) { OSname = &#39;unixOS&#39;; } if (appVersion.indexOf(&#34;Linux&#34;) != -1) { OSname = &#39;linuxOS&#39;; } angular.module(&#39;myApp&#39;). controller(&#39;dashboardController&#39;, function ($scope, $http, $sessionStorage, $window, $location, useragent) { $scope.device = useragent.device(); $scope.browserName = useragent.browser(); $scope.platform = useragent.platform(); $scope.cookie = useragent.cookie(); $scope.version = useragent.version(); $scope.versiontrue = useragent.version(true); $scope.OS = useragent.OS(); $scope.appVersion = useragent.appVersion(); $scope.screen = useragent.screen(); $http.get(&#34;https://ipinfo.io/json&#34;).then(function (response) { $scope.ip = response.data.ip; }); }).factory(&#39;useragent&#39;, function () { return { browser: function () { return browserName; }, device: function () { return mobile.any() ? mobile.any().toString() : &#39;Desktop&#39;; }, platform: function () { return platform; }, version: function (v) { return v ? fullVersion : BrMajorVersion; }, OS: function () { return OSname; }, cookie: function () { return cookie; }, appVersion: function () { return appVersion; }, screen: function () { return screensize; } } });</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/152863/Retrieve-Device-and-Login-details-of-User-in-AngularJS/https://www.aspforums.net:443/Threads/152863/Retrieve-Device-and-Login-details-of-User-in-AngularJS/Mon, 05 Aug 2019 01:00:31 GMT