Is there a way to cha开发者_高级运维nge/modify the value of user-agent string permanently using JavaScript?
You mean from a web page inside a browser?
No, definitely not. Neither permanently nor temporarily.
You can't even modify navigator.userAgent
(at least on my test with Firefox).
So, no.
Try this.
alert("User-agent header sent: " + navigator.userAgent);
navigator.__defineGetter__('userAgent', function(){ return "Hello" });
alert("User-agent header sent: " + navigator.userAgent);
精彩评论