我有以下代码:
var currentServerlist = [];
var newServerIp = document.getElementById('add_server').value;
if( CurrentServerIP != newServerIp )
{
$('#failoverServers td.row_selector').each(function() {
var row = $(this).closest('tr');
var serverIp = row.find('td[rel=ip]').text();
currentServerlist.push(serverIp);
});
if(currentServerlist.lastIndexOf(newServerIp) != -1)
{
return true;
}
return false;
}
但我发现lastIndexOf在InternetExplorer中不起作用(它在Chrome中起作用)。
我怎样才能解决这个问题?
根据ES5兼容性表 http://kangax.github.com/es5-compat-table/, Array.prototype.lastIndexOf
除 IE8 及以下版本外,所有浏览器均支持。
如果您需要支持此类浏览器,您可以使用各种浏览器之一填充物 https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/lastIndexOf可用的(或更完整的 ES5 polyfill 解决方案 https://github.com/kriskowal/es5-shim).
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)