javascript - Changing useragent if ipad -


what want detect if user using ipad, change useragent iphone. want ensure page detects change before page load..

i've tried doing no luck.

<script type="text/javascript"> var navigator = new object;  var useragent = httpcontext.current.request.useragent.tolower(); if (useragent.contains("ipad;")) {     navigator.useragent = 'iphone'; } </script> 

the useragent readonly can not set anything.

you using httpcontext.current.request.useragent.tolower(); not valid javascript. c# browser can not execute.

instead @ navigator.useragent

var nav = ''; if (navigator.useragent.indexof('ipad') != -1) {   nav = 'its ipad'; } else {   nav = 'its other device'; }  console.log(nav); 

Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -