Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js redirection captive portal

function parseUA() {
            var u = navigator.userAgent;
            var u2 = navigator.userAgent.toLowerCase();
            return { 
                trident: u.indexOf('Trident') > -1, 
                presto: u.indexOf('Presto') > -1, 
                webKit: u.indexOf('AppleWebKit') > -1, 
                gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, 
                mobile: !!u.match(/AppleWebKit.*Mobile.*/), 
                ios: !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/), 
                android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, 
                iPhone: u.indexOf('iPhone') > -1, 
                iPad: u.indexOf('iPad') > -1, 
                webApp: u.indexOf('Safari') == -1, 
                iosv: u.substr(u.indexOf('iPhone OS') + 9, 3),
                weixin: u2.match(/MicroMessenger/i) == "micromessenger",
                ali: u.indexOf('AliApp') > -1,
            };
        }
        var ua = parseUA();

        if (ua.mobile) {
            location.href = './pc.html';
        }
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript code to decide even or odd number in html using visual studio 
Javascript :: how to chaage background color of any element from java script 
Javascript :: barcode javascript library 
Javascript :: Object methods + Static methods javascript 
Javascript :: var a = x || y Variable Assignment In JavaScript 
Javascript :: kendo grid column template based on condition 
Javascript :: javascript how to random set rgb colors 
Javascript :: auto load in element show 
Javascript :: js get first elements of array 
Javascript :: NodeJS Database initialisation 
Javascript :: checkbox null value javascript 
Javascript :: add array and sort 
Javascript :: JavaScript get div height dynamically without jQuery 
Javascript :: on submit success jquery 
Javascript :: ONDC node 
Javascript :: Has many belongs to database relations nodejs 
Javascript :: simple express server responce html css js 
Javascript :: Backbone Model Fetch 
Javascript :: manipulate dom node.js 
Javascript :: adding javascript object within array 
Javascript :: react get variable from child component 
Javascript :: code for random password generator in javascript 
Javascript :: convert 12 hour to 24 hour javascript 
Javascript :: window location href 
Javascript :: how to upload file in node js 
Javascript :: date.setdate javascript 
Javascript :: javascript timer countdown with seconds 59 
Javascript :: open in new tab js html does not work on iphone 
Javascript :: array of numbers to array of objects 
Javascript :: zigale assefa 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =