user3576592
user3576592

Reputation:

Javascript Hide an If statement with another If Statement

I want to hide an If statement if the user is on a mobile device. I tried with another if statement:

if(version.major === 0) {
                document.write('Du benutzt aktuell keinen Flash Player! ');
                flashPlayerVersion.style.display = 'none';
            }

and with this If statement I tried to hide the other one if the user is a mobile user.

 var mobile = (/iphone|playbook|windows phone|mobile|silk browser|android.webkit.WebView|web app runtime|kindle|kindle fire|blackberry|ipod|ipad|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
    if (mobile) {
        FlashNotification.style.display = 'none';

    }

Now i want to hide the flashPlayerVersion ...

Hope you could understand my question ^^

Upvotes: 0

Views: 49

Answers (3)

IronAces
IronAces

Reputation: 1883

I'm not for browser detection, it becomes very tricky when you're factoring in mobile devices. Detect if flash is installed on users device. Not entirely sure I've understood your question...

var _flash_installed = ((typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") || (window.ActiveXObject && (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) != false));

Upvotes: 0

Vincent Schöttke
Vincent Schöttke

Reputation: 4716

Just put one if inside the other:

if (version.major === 0) {
    var mobile = (/iphone|playbook|windows phone|mobile|silk browser|android.webkit.WebView|web app runtime|kindle|kindle fire|blackberry|ipod|ipad|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));

    if (mobile) {
        FlashNotification.style.display = 'none';
    } else {
        document.write('Du benutzt aktuell keinen Flash Player! ');
        flashPlayerVersion.style.display = 'none';
    }
}

Upvotes: 0

Daniel Rossko Rosa
Daniel Rossko Rosa

Reputation: 362

What about this (if i understand your question correctly):

var mobile = (/iphone|playbook|windows phone|mobile|silk browser|android.webkit.WebView|web app runtime|kindle|kindle fire|blackberry|ipod|ipad|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
if (mobile) {
    FlashNotification.style.display = 'none';

}else{
    if(version.major === 0) {
            document.write('Du benutzt aktuell keinen Flash Player! ');
            flashPlayerVersion.style.display = 'none';
        }
}

Upvotes: 1

Related Questions