我正在使用JavaScript中的拆分函数。它在Firefox和Chrome中运行良好,但当我调用split函数时,IE显示一个错误。有没有办法使用像split这样的其他函数?
发布于 2011-06-21 17:08:12
split Method
它完全由IE8支持
split method for JScript 5.6
IE6也完全支持它
使用.split(/\s+/)的Live example
已在IE9标准、IE9 IE8模式、IE9 IE7模式和IE9 quirks模式下测试。一切正常。
编辑:
事实证明,您的实际问题是使用.textContent。这在IE中不起作用。有两种选择。
功能检测:
var str;
if (el.textContent) {
str = el.textContent;
} else {
str = el.innerText;
}.nodeValue:
var str = el.nodeValue;
https://stackoverflow.com/questions/6422355
复制相似问题