OPerating system
-
Hi all, I want to check the operating system of the user before i load the web page. Step 1 . I did insert the following into the tags of my page: <--> function checkOS() { if(navigator.userAgent.indexOf('IRIX') != -1) { var OpSys = "Irix"; } else if((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('95') != -1)) { var OpSys = "Windows95"; } else if(navigator.userAgent.indexOf('Win') != -1) { var OpSys = "Windows3.1 or NT"; } else if(navigator.userAgent.indexOf('Mac') != -1) { var OpSys = "Macintosh"; } else { var OpSys = "other"; } return OpSys; } // --> </--> Step 2. I inserted the following anywhere inside the tags: <--> var OpSys = checkOS(); document.write(OpSys); //--> </--> However, Nothing comes up when i run the page? Regards kibrom
-
Hi all, I want to check the operating system of the user before i load the web page. Step 1 . I did insert the following into the tags of my page: <--> function checkOS() { if(navigator.userAgent.indexOf('IRIX') != -1) { var OpSys = "Irix"; } else if((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('95') != -1)) { var OpSys = "Windows95"; } else if(navigator.userAgent.indexOf('Win') != -1) { var OpSys = "Windows3.1 or NT"; } else if(navigator.userAgent.indexOf('Mac') != -1) { var OpSys = "Macintosh"; } else { var OpSys = "other"; } return OpSys; } // --> </--> Step 2. I inserted the following anywhere inside the tags: <--> var OpSys = checkOS(); document.write(OpSys); //--> </--> However, Nothing comes up when i run the page? Regards kibrom
kibromg wrote:
Step 2. I inserted the following anywhere inside the tags: <--> var OpSys = checkOS(); document.write(OpSys); //--> </-->
You are using document.write inside a script. I guess it wont work. . Instead you can have a alert statement.
kibromg wrote:
<--> function checkOS() { if(navigator.userAgent.indexOf('IRIX') != -1) { var OpSys = "Irix"; } else if((navigator.userAgent.indexOf('Win') != -1) && (navigator.userAgent.indexOf('95') != -1)) { var OpSys = "Windows95"; } else if(navigator.userAgent.indexOf('Win') != -1) { var OpSys = "Windows3.1 or NT"; } else if(navigator.userAgent.indexOf('Mac') != -1) { var OpSys = "Macintosh"; } else { var OpSys = "other"; } <b>alert("OpSys");</b> return OpSys; } // --> </-->