写一个设置 Cookie 值的封装函数

10 查阅

写一个设置 Cookie 值的封装函数

参考答案:

解析:

(1)encodeURI() 转换字符编码为统一编码(涉及中文编码)。(2)toUTCString() 将时间转换为字符串,Cookie 只能接收字符串形式。function setCookie(key, value, t) {var oDate = new Date();oDate.setDate(oDate.getDate() + t);

函数