Javascript函数的弃用unescape() [英] Deprecation of Javascript function unescape()

查看:964
本文介绍了Javascript函数的弃用unescape()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 W3学校,unescape()JavaScript函数已被弃用。
网站声明,

According to W3 Schools the unescape() JavaScript function has been deprecated. The site states,


unes​​cape()函数在JavaScript 1.5版中已弃用。使用
decodeURI( )或者是decodeURIComponent()代替。

"The unescape() function was deprecated in JavaScript version 1.5. Use decodeURI() or decodeURIComponent() instead."

我应该通过并替换unescape()的所有实例吗?

Should I go through and replace all instances of unescape()?

JavaScript函数的弃用是否是Web开发人员关心并主动更新其JavaScript代码的东西?

Is the deprecation of JavaScript functions something that web developers concern themselves with and actively update their JavaScript code?

或者我可以期待大多数浏览器在可预见的未来会支持JavaScript 1.5吗?

or can I expect that most browsers will support JavaScript 1.5 in the foreseeable future?

推荐答案

根据 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape 您应该更新旧脚本:

According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape you should update your old scripts:


此功能已从Web标准中删除。虽然有些浏览器可能仍然支持它,但它正在被删除。不要在旧项目或新项目中使用它。使用它的页面或网络应用程序可能随时中断。

This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped. Do not use it in old or new projects. Pages or Web apps using it may break at any time.



快速修复?



修复它可能就像在JS中添加一行来添加 unescape()方法(如果不存在)一样简单。

A Quick Fix?

Fixing it could be as simple as dropping a line into your JS to add in an unescape() method if one doesn't exist.

window.unescape = window.unescape || window.decodeURI;

这篇关于Javascript函数的弃用unescape()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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