1

is it possible to modify the userAgent using JavaScript? I personally only know the getter window.navigator.userAgent, but this won't help me.

3
  • The HTTP header? No, you cannot modify the (request) headers using JavaScript. navgiator.userAgent? Only by using a trick. Commented Feb 22, 2012 at 15:53
  • Are you using the WebBrowser control, can you use it in the Navigate method? stackoverflow.com/questions/7631740/… Commented Feb 22, 2012 at 15:54
  • the wp7 webbrowser control is a little bit different i think, there is no standard-solution for this. Commented Feb 22, 2012 at 16:21

1 Answer 1

1

This should work.

navigator.__defineGetter__('userAgent', function(){
    return 'foo' // customized user agent
});

navigator.userAgent; // 'foo'​​​​​​​​​​​​​​​​​​
Sign up to request clarification or add additional context in comments.

3 Comments

Or Object.defineProperty(navigator,'userAgent', {value:'foo'});
the last line is just the proof, isn't it? I'll try this.
Yup, just to make sure. I haven't tested in all browsers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.