如何使用javaScript更改浏览器User-Agent标头? [英] How to change browser User-Agent Header with javaScript?

查看:1032
本文介绍了如何使用javaScript更改浏览器User-Agent标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码更改了浏览器控制台打印的属性(通过javaScript访问时),而不是与标头一起发送的实际Use-Agent字符串。

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)'; }
});


推荐答案

从页面本身是不可能的。用户代理字符串(在HTTP请求标头中发送)只能通过浏览器扩展或浏览器配置进行更改。

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.

这篇关于如何使用javaScript更改浏览器User-Agent标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆