Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
815 views
in Technique[技术] by (71.8m points)

javascript - IE8 Object doesn't support this property or method (Math.max.apply)

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. works perfectly on Chrome/Safari...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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)

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

Or.

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

Or.

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(); }));

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.8k users

...