Detect Android Device and redirect to Page using jQuery

Last Reply 15 days ago By pandeyism

Posted 15 days ago

hello,

 

i have testing url of my website, which is live, i want any one try to open it on browser desktop or mobile it should redirect user to my main site like

testing.xyz.com if some one open it on browser it should redirect user to xyz.com so user cannot browse my testing url

You are viewing reply posted by: pandeyism 15 days ago.
Posted 15 days ago

Hi nauna,

Please refer below sample to detect android devices.

Reference: Detect Browser Name, Version, Platform, OS, Mobile or Desktop in JavaScript using jQuery

HTML

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-browser/0.1.0/jquery.browser.min.js"></script>
<script type="text/javascript">
    $(function () {
        if ($.browser.platform == "win") {
            window.location.href = "https://www.aspforums.net/";
        }
        if ($.browser.platform == "android") {
            window.location.href = "https://www.aspsnippets.com/";
        }
    });
</script>

Demo