如何使用javaScript更改浏览器User

编程入门 行业动态 更新时间:2024-10-28 03:24:08
本文介绍了如何使用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

本文发布于:2023-11-12 17:07:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582052.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   浏览器   javaScript   User

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!