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 - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -