1

I am trying to find out which operation system that user used for my web?

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = "Platform: " + navigator.platform;
    document.getElementById("demo").innerHTML = x;
}
</script>

but i would to save the output in text in order to save it in my database ! How can i do it?? thanks in advance

Maximilian Peters
  • 24,648
  • 11
  • 64
  • 80
Abo Khalid
  • 11
  • 1
  • 1
    Why not do it in PHP? `$_SERVER['HTTP_USER_AGENT']` contains that info. You did put PHP in your tags – Forbs Apr 10 '18 at 22:01
  • What do you mean by saving output as a text? Variable `x` already holds a string (text). – Matus Dubrava Apr 10 '18 at 22:01
  • ^.. and if you are willing to save it in a database you need to send it to a server side language, PHP for example with AJAX or just as @Forbs mentioned use `$_SERVER` to get whatever data you want. – Spoody Apr 10 '18 at 22:02

1 Answers1

0

If you are looking for the Windows version, use the oscpu property of the navigator object instead of platform.

var osName = navigator.oscpu;

For more details, see this post

Hope it helps

Al Imran
  • 71
  • 2