简体   繁体   中英

How do I disable stellar.js for safari browsers?

I am using stellar.js for this website - www.jaisalmera.com - how do I disable the parallax for safari and internet explorer browsers? I have already disabled it for mobile devices with this -

if ($(window).width() > 800) {
    $(window).stellar();
    }

Can someone let me know how to do this for Safari / IE browsers also? From research I have seen that the parallax scrolling doesn't work for these.

Thank you!

I am pretty late in the party but hoping to get some cake and also to help someone out having the same requirement-

You can use the below script to detect the browser type by its feature detection as specified in this post .

    var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
    // Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
    var isFirefox = typeof InstallTrigger !== 'undefined';   // Firefox 1.0+
    var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
    // At least Safari 3+: "[object HTMLElementConstructor]"
    var isChrome = !!window.chrome && !isOpera;              // Chrome 1+
    var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6

After that you can turn off the stellar initialization for specific browsers like-

if(!isSafari || !isIE)
{
    $(window).stellar();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM