iT邦幫忙

0

navigator.userAgent

  • 分享至 

  • xImage

在網頁中,按了F12,看到了如下警示訊息

A page or script is accessing at least one of navigator.userAgent, navigator.appVersion, and navigator.platform. In a future version of Chrome, the amount of information available in the User Agent string will be reduced.
To fix this issue, replace the usage of navigator.userAgent, navigator.appVersion, and navigator.platform with feature detection, progressive enhancement, or migrate to navigator.userAgentData.

意思應該是說 G老大將來要抛棄這幾個小傢伙不用了,叫我們早點準備迎新送舊?
搜尋了一下自己的程式,幾乎都是一些工具庫用到它,jquery也在其中,加上其它林林總總的外掛,總數量還真不少。

我們要怎麼去處理它呢?不理它將來會怎樣?

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
純真的人
iT邦大師 1 級 ‧ 2021-08-13 18:24:01

他說在Chrome以後的新版本將移除navigator.userAgent, navigator.appVersion, and navigator.platform.不顯示@@..
所以先判斷navigator.userAgentData是否存在~
才改用舊的navigator.userAgent去解析~
參考:
https://web.dev/migrate-to-ua-ch/

ckp6250 iT邦好手 1 級 ‧ 2021-08-13 19:55:55 檢舉

感恩,
搞得真複雜,費這麼大的勁,目的何在呢?有何實質效益呢?

習慣就好~業界的手法~
就像Win7用得好好的~為何用Win10

我要發表回答

立即登入回答