How to change browser User-Agent Header with javaScript?

折月煮酒 提交于 2020-02-16 00:42:08

问题


Following code changes property printed (when accessed through javaScript) by browser console and not the actual Use-Agent string sent with the header.

Object.defineProperty(navigator, 'userAgent', {
    get: function () { return 'Mozilla/5.0 (Windows NT 6.2; WOW64; 
    rv:28.0) Gecko/20100101 Firefox/28.0)'; }
});

回答1:


This isn't possible from the page itself. The user agent string (as sent in the HTTP request headers) can only be changed via browser extension or browser configuration.



来源:https://stackoverflow.com/questions/58005954/how-to-change-browser-user-agent-header-with-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!