Solution: How to automatic download with os detection?

Development | Software Testing
Author
Description
I want to create a webpage with javascript that automatically detects which os the user has. and then download the correct installation file.

here is my code

html
<!DOCTYPE html>
<html>
<<body>
    <iframe id="my_iframe" style="display:none;"></iframe>
     <script src="os.js"></script> 
    </body>
</html>

javascript
var OSName = "Unknown OS";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
if (OSName =  "Windows"){
    window.location = "https://test.leonwolvekamp.nl/TeamViewer_Setup.exe"
    };
if (OSName = "MacOS"){
     window.location = "https://test.leonwolvekamp.nl/TeamViewer.dmg"
    }
    };
But the download won't start
Attachments
Solutions
Open os.js and delete or comment line 16.
on October 02nd, 2018 (7:40 pm)
What masters said
You must sign in to comment!!
All comments
This solution has not been commented yet.
We use cookies to give you the best possible experience on our site. By continuing to use the site you agree to our use of cookies. Find out more Accept