0

Is there a way to change/modify the value of user-agent string permanently using JavaScript?

3 Answers 3

1

You mean from a web page inside a browser?

No, definitely not. Neither permanently nor temporarily.

Sign up to request clarification or add additional context in comments.

Comments

1

You can't even modify navigator.userAgent (at least on my test with Firefox).

So, no.

Comments

-1

Try this.

alert("User-agent header sent: " + navigator.userAgent);
navigator.__defineGetter__('userAgent', function(){ return "Hello" });
alert("User-agent header sent: " + navigator.userAgent);

1 Comment

-1 This is a bad hack, and doesn't actually change anything. You're just overriding the getter, which will have to be done on every single page, and if you're planning on doing that then why are you even bothering to check userAgent in the first place?

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.