1. //alert( oDiv.getAttribute('class') ); // ie678 以下面找不到class
//alert(oDiv.getAttribute('data-time')); // 自定义绑定的数据是全兼容的
//alert( oDiv.getAttribute('id') ); // 全兼容
oDiv.setAttribute('class','wrap22'); // 全兼容
//oDiv.removeAttribute('class'); // ie678下面class 失去作用
//oDiv.removeAttribute('class');
总结: 问题出现在寻找class的问题上,因此在ie678中使用的时候需要重新写 getAttribute, removeAttribute。不兼容ie678则可以完全忽略。
2. 编码问题
// decodeURI()
var str = 'http://www.baidu.com/qiu yan long/list/首页';
//alert( unescape(escape(str)) );
// escape和unescape在es3以后不建议使用,但是还是可以使用,推荐使用encodeURI 和 encodeURLComponent();
var re = encodeURI(str); // 只编码空格跟中文字符串
var rr = encodeURIComponent(str); // 所有的都会进行编码
document.write( re +'<br/>');
//http://www.baidu.com/qiu%20yan%20long/list/%E9%A6%96%E9%A1%B5
document.write( rr +'<br/>');
//http%3A%2F%2Fwww.baidu.com%2Fqiu%20yan%20long%2Flist%2F%E9%A6%96%E9%A1%B5
document.write( decodeURI(re)+'<br/>' );
document.write( decodeURIComponent(rr)+'<br/>' );
//alert(oDiv.getAttribute('data-time')); // 自定义绑定的数据是全兼容的
//alert( oDiv.getAttribute('id') ); // 全兼容
oDiv.setAttribute('class','wrap22'); // 全兼容
//oDiv.removeAttribute('class'); // ie678下面class 失去作用
//oDiv.removeAttribute('class');
总结: 问题出现在寻找class的问题上,因此在ie678中使用的时候需要重新写 getAttribute, removeAttribute。不兼容ie678则可以完全忽略。
2. 编码问题
// decodeURI()
var str = 'http://www.baidu.com/qiu yan long/list/首页';
//alert( unescape(escape(str)) );
// escape和unescape在es3以后不建议使用,但是还是可以使用,推荐使用encodeURI 和 encodeURLComponent();
var re = encodeURI(str); // 只编码空格跟中文字符串
var rr = encodeURIComponent(str); // 所有的都会进行编码
document.write( re +'<br/>');
//http://www.baidu.com/qiu%20yan%20long/list/%E9%A6%96%E9%A1%B5
document.write( rr +'<br/>');
//http%3A%2F%2Fwww.baidu.com%2Fqiu%20yan%20long%2Flist%2F%E9%A6%96%E9%A1%B5
document.write( decodeURI(re)+'<br/>' );
document.write( decodeURIComponent(rr)+'<br/>' );