Question

I'm using the Modify Headers plugin for Firefox in order to change the user-agent. The reason I need to do this (for testing), is to load different css depending on if it is an iOS or Android phone.

Running this script

  <script type="text/javascript">
    var agent = navigator.userAgent.toLowerCase();
    alert(agent);
  </script>

I always get this output:

mozilla/5.0 (windows nt 6.1; wow64; rv:26.0) gecko/20100101 firefox/26.0

even though I can see in the following in Thunderbird:

User-Agent: Mozilla/5.0 (iPad; CPU OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko ) Version/5.1 Mobile/9B176 Safari/7534.48.3

Is this a Firefox specific issue?

Was it helpful?

Solution

Modifying the user agent via the headers will indeed change the UA string that the server sees.

However, it doesn't mean that you're actually changing the User agent string that the browser knows about.

You're querying the UA string via javascript; that will be getting the actual UA string in the browser; nothing to do with the headers that have been sent to the server.

If you want to override the UA string properly, there are firefox extensions that specialise in doing so. I suggest you use one of them, rather than a generic header override extension.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top