IE8对象不支持此属性或方法(Math.max.apply) [英] IE8 Object doesn't support this property or method (Math.max.apply)

查看:480
本文介绍了IE8对象不支持此属性或方法(Math.max.apply)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是一个巨大的JS作家 - 所以这可能很容易 - 但我在以下代码行中遇到上述错误:

I'm not a huge JS writer - so this maybe really easy - but I'm getting the above error in the following line of code:

max_height = Math.max.apply(Math, this.headlines.map(function(e) {
        return jQuery(e).height(); }));

这不是我的代码 - 但任何有关如何修复此问题的指示都将不胜感激!谢谢

Its not my code - but any pointers on how to fix this would be appreciated! Thanks

PS。在Chrome / Safari上完美运行...

PS. works perfectly on Chrome/Safari...

推荐答案

我的第一个(唯一)观察,就是你正在使用 .map()在Javascript 1.6中定义,IE8仅支持Javascript 1.5(据我所知)

My first (only) observation, is that you're using .map() which is defined in Javascript 1.6 and IE8 only supports Javascript 1.5 (as far as I'm aware)

也许尝试使用polyfill或pollyfils库,如modernizr等。
请参阅: https://github.com/kriskowal/ es5-shim

Perhaps try using a polyfill or a library of pollyfils like modernizr etc. See: https://github.com/kriskowal/es5-shim

或。

编写代码,使其不依赖于不支持的功能通过IE8。

Write your code such that it doesnt rely on features unsupported by IE8.

或。

看到你正在使用jQuery。您可以使用jquery提供 .map()功能,请参阅: http ://api.jquery.com/jQuery.map/

Seeing as you're using jQuery. you could use jquery to provide the .map() functionality, see: http://api.jquery.com/jQuery.map/

max_height = Math.max.apply(Math, jQuery.map(this.headlines, function(e) {
    return jQuery(e).height(); }));

这篇关于IE8对象不支持此属性或方法(Math.max.apply)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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