[Script] Javascript detectare browser

Locked
User avatar
! Manticore ♛
Membru
Membru
Posts: 1542
Joined: 8 years ago
Location: New York , SUA
Has thanked: 0
Been thanked: 0
Zodiac:
Age: 27
Status: Offline

7 years ago

Javascript detectare browser.

Code: Select all

<script>
var isMobile = {
    Android: function() {
        return navigator.userAgent.match(/Android/i);
    },
    BlackBerry: function() {
        return navigator.userAgent.match(/BlackBerry/i);
    },
    iOS: function() {
        return navigator.userAgent.match(/iPhone|iPad|iPod/i);
    },
    Opera: function() {
        return navigator.userAgent.match(/Opera Mini/i);
    },
    Windows: function() {
        return navigator.userAgent.match(/IEMobile/i) || navigator.userAgent.match(/WPDesktop/i);
    },
    any: function() {
        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
    }
};
</script> 
Se utilizeaza asa:

Code: Select all

$(document).ready(function(){
    if( isMobile.any() ) {
        // codul...
    }
    }); 
Image Image

Image

© ! Manticore ♛

"Many things that seems threatening in the dark,become more welcoming when we shine a light on them."
"Maybe for the world you are just a person,but for a person you are the entire world."
"Nothing is impossible,the word itself says <<I'm Possible>>."
"If the pain will ever speak,then my pain will scream."
''The fastest way to happiness is to avoid the reality."

Image
Locked

Return to “Script-uri”