Issue Description:
Recently Business user
has asked me to display the Browser Operating system to the top of a SharePoint
Portal home page. So if some SharePoint functionality does not support for
Windows XP or other operating system, user should be aware of that.
Restriction: We should
not use the Server side code
Diagnosis:
I planned to go with
java script solution to get the OS details. I have searched over the internet
and found some of the solution. One of the solution I am going to use below.
Solution:
I have added a content Edit webpart to the Home
page of the Portal.
Added the below HTML code to the Content Editor.
HTML Code:
create a div element with id "OSMessage" and give the style="Float:right".
Add below code to java script tag
_spBodyOnLoadFunctionNames.push("GetOS");
function GetOS()
{
var nAgt = navigator.userAgent;
// system
var os;
var
clientStrings = [
{s:'Windows 3.11', r:/Win16/},
{s:'Windows 95', r:/(Windows 95|Win95|Windows_95)/},
{s:'Windows ME', r:/(Win 9x 4.90|Windows ME)/},
{s:'Windows 98', r:/(Windows 98|Win98)/},
{s:'Windows CE', r:/Windows CE/},
{s:'Windows 2000', r:/(Windows NT 5.0|Windows 2000)/},
{s:'Windows XP', r:/(Windows NT 5.1|Windows XP)/},
{s:'Windows Server 2003', r:/Windows NT 5.2/},
{s:'Windows Vista', r:/Windows NT 6.0/},
{s:'Windows 7', r:/(Windows 7|Windows NT 6.1)/},
{s:'Windows 8.1', r:/(Windows 8.1|Windows NT 6.3)/},
{s:'Windows 8', r:/(Windows 8|Windows NT 6.2)/},
{s:'Windows NT 4.0', r:/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/},
{s:'Windows ME', r:/Windows ME/},
{s:'Android', r:/Android/},
{s:'Open BSD', r:/OpenBSD/},
{s:'Sun
OS', r:/SunOS/},
{s:'Linux', r:/(Linux|X11)/},
{s:'iOS',
r:/(iPhone|iPad|iPod)/},
{s:'Mac OS
X', r:/Mac OS X/},
{s:'Mac
OS', r:/(MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},
{s:'QNX',
r:/QNX/},
{s:'UNIX',
r:/UNIX/},
{s:'BeOS',
r:/BeOS/},
{s:'OS/2',
r:/OS\/2/},
{s:'Search
Bot', r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask
Jeeves\/Teoma|ia_archiver)/}
];
for (var id in
clientStrings) {
var cs =
clientStrings[id];
if
(cs.r.test(nAgt)) {
os =
cs.s;
break;
}
}
var divMessage=document.getElementById('OSMessage');
divMessage.innerHTML="";
divMessage.innerHTML = divMessage.innerHTML + 'Your Computer
Operating system is '+os;
}
After adding this piece of code to the content Editor, you
will get the output as similar to the below screen shot.

Here in this example I have Operation system as Windows 7. So
outputs will is “Your system Operating System is Windows 7”.
Need Your Help: I want to know whether the service Packs information of
Operating system also we can get using the script that I am not able to achieve. Please
help me if anybody has the solution.
Always appreciate your comments. And yes I got most of the code from
Stackoverflow.com.
No comments:
Post a Comment