Get latest version of Safari browser.

bfuchs
bfuchs used Ask the Experts™
on
Hi Experts,

I have following code for detecting if user has latest version of Chrome and Firefox browsers.

   else if(bowser.chrome) {
        var translate_bowser_osname = {"Windows":"win", "macOS":"mac"};
        $.getJSON("https://omahaproxy.appspot.com/all.json?os=" + translate_bowser_osname[bowser.osname] + "&channel=stable", function(data) {
            var latest = data[0].versions[0].current_version.match(/\d*\.{0,1}\d+/).pop() * 1;
            // FOR TESTING PURPOSE WE SET CURRENT BROWSER VERSION TO 77 (CURRENT IS 78.x.y)
            //if(version<latest) { // UNCOMMENt THIS LINE TO COMARE THE RIGHT CHROME USER VERSION AND COMMENT NEXT ONE
            if(77<latest) {
                var confirMsg = "please update your browser to the latest version";
                saveBrowserInfos("https://www.youtube.com/watch?v=RyI7RyEEPxM", confirMsg);
            }
            else {
                loginForm.submit();
            }
        });
    }

Open in new window


    else if(bowser.firefox) {
        $.getJSON("https://product-details.mozilla.org/1.0/firefox_versions.json", function(data) {
            var latest = data["LATEST_FIREFOX_VERSION"].match(/\d*\.{0,1}\d+/).pop() * 1;
            if(version<latest) {
                var confirmMsg = "please update your browser to the latest version";
                saveBrowserInfos("https://www.youtube.com/watch?v=K9LZmxT9K30", confirmMsg);
            }
            else {
                loginForm.submit();
            }
        });
    }

Open in new window


Would like to add checking for Safari as well.

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
apple has stopped updating Safari on Windows platform!
Hi,
And whats about other platforms?
Thanks,
Ben
Jackie Man IT Manager
Top Expert 2010

Commented:
And whats about other platforms?

The other platforms are Apple OS of OS X and iOS.
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

David FavorFractional CTO
Distinguished Expert 2018

Commented:
https://Modernizr.com provides far better browser support.

Modernizr allows writing one set of code for all browsers, then Modernizr handles fix up, via shims, to craftily provide browser support through Javascript + CSS hacks... behind the scenes...

Check out Modernizr as a simple way to accomplish supporting current browsers, along with any potential future browser that will ever be released... along with fixing many old browsers, without any coding.
Hi,

The other platforms are Apple OS of OS X and iOS.
Okay, so for the other platforms I need that checking.

@David,

I forward to our consultant, will see if we can make use of that, however we need the option to display a different upgrade link according to the browser users have.

Thanks,
Ben
Apple updates the safari browser through its updates.  You don't need to check it separately.
@serialband,

But I do see users having old versions of safari, and we want to prevent it as we use Caspio app and its not supporting older versions.

Thanks,
Ben
If they have older versions of safari, then it's because they have older macs or they're not even updating security patches on their Mac.  If that's the case you have much bigger issues.

If you have remote login enabled, you can update their Macs for them on the command line.

softwareupdate -ia will update their Safari patches, along with any Mac system patches.
If they have older versions of safari, then it's because they have older macs or they're not even updating security patches on their Mac.  If that's the case you have much bigger issues.
Right, and this is why we need the code to check if the reason is the old Mac or missing security patches, which in that case the system should popup an alert as coded above for other browsers.

Thanks,
Ben
Multitechnician
Top Expert 2014
Commented:
so what can of alert are you going to display to Apple users?

iOS -> browser not supported
MacOS -> upgrade your operating system

    else if(bowser.safari) {
        if(bowser.osname == "Windows") {
            var confirmMsg = "Apple no longer offers Safari updates for Windows.\nSafari 5.1.7 for Windows was the last version made for Windows, and it is now outdated.";
            saveBrowserInfos("https://www.apple.com/fr/mac/", confirmMsg);
        }
        else if(bowser.osversion != "10.15.1") { // you need to maintain this value manually every time Apple launch a new collection of devices
                if(bowser.osname=="iOS") {
                    var confirmMsg = "your browser is not supported";
                    saveBrowserInfos("https://www.apple.com/iphone-11-pro/", confirmMsg);
                }
                else {
                    var confirmMsg = "please update your operating system to the latest version";
                    saveBrowserInfos("https://www.youtube.com/watch?v=wdEnblZgEVw", confirmMsg);
                }
        }
        else {
            loginForm.submit();
        }
    }

Open in new window

Thank you!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial