admin管理员组文章数量:1198394
I get this error in IE 11:
Object doesn't support property or method isNaN
JavaScript
jQuery(document).ready(function($) {
var $total = $('#total'),
$value = $('.value');
$firstName = $('#firstname');
$lastName = $('#lastname');
$tour = $('#tour');
$pledge = $('#pledge');
$currency = $('#currency');
$distance = $('#distance');
$riders = $('#riders');
$(':input').on('input change', function(e) {
var total = 1;
$value.each(function(index, elem) {
if(!Number.isNaN(parseFloat(this.value)))
total = total * parseFloat(this.value);
});
$total.val(total/10);
$('#pledgefirstname').text($firstName.val());
$('#pledgelastname').text($lastName.val());
$('#pledgetour').text($tour.val());
$('#pledgepledge').text($pledge.val());
$('#pledgecurrency').text($currency.val());
$('#pledgecurrency2').text($currency.val());
$('#pledgecurrency3').text($currency.val());
$('#pledgecurrency4').text($currency.val());
$('#pledgetotal').text($total.val());
$('#pledgetotal2').text($total.val());
$('#pledgedistance').text($distance.val());
$('#pledgeriders').text($riders.val());
});
});
I get this error in IE 11:
Object doesn't support property or method isNaN
JavaScript
jQuery(document).ready(function($) {
var $total = $('#total'),
$value = $('.value');
$firstName = $('#firstname');
$lastName = $('#lastname');
$tour = $('#tour');
$pledge = $('#pledge');
$currency = $('#currency');
$distance = $('#distance');
$riders = $('#riders');
$(':input').on('input change', function(e) {
var total = 1;
$value.each(function(index, elem) {
if(!Number.isNaN(parseFloat(this.value)))
total = total * parseFloat(this.value);
});
$total.val(total/10);
$('#pledgefirstname').text($firstName.val());
$('#pledgelastname').text($lastName.val());
$('#pledgetour').text($tour.val());
$('#pledgepledge').text($pledge.val());
$('#pledgecurrency').text($currency.val());
$('#pledgecurrency2').text($currency.val());
$('#pledgecurrency3').text($currency.val());
$('#pledgecurrency4').text($currency.val());
$('#pledgetotal').text($total.val());
$('#pledgetotal2').text($total.val());
$('#pledgedistance').text($distance.val());
$('#pledgeriders').text($riders.val());
});
});
Share
Improve this question
edited Mar 20, 2014 at 16:27
cookie monster
11k4 gold badges33 silver badges45 bronze badges
asked Mar 20, 2014 at 15:56
square_eyessquare_eyes
1,2713 gold badges24 silver badges54 bronze badges
14
|
Show 9 more comments
3 Answers
Reset to default 13Number.isNaN
This is an experimental technology, part of the Harmony (EcmaScript 6) proposal. Because this technology's specification has not stabilized, check the compatibility table for usage in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future version of browsers as the spec changes.
It is still not supported by most of the browsers (including IE11).
You should use a standard isNaN
method instead:
if (isNaN( parseFloat(this.value) )) { ... }
If you are using ES6 with Babel in React. You can do like this:
// pollyfills for older browsers
// core-js v2.x.x:
import 'core-js/es6/number';
// core-js v3.x.x:
import 'core-js/es/number';
Add dependencies in package.json for
"dependencies": {
"core-js": "^2.5.5",
}
I had a similar problem except it was coming from React after it compiled, bundled, and minified. To solve this, I redefined the Number.isNaN
:
if (!Number.isNaN) {
Object.defineProperty(Number, 'isNaN', {
value: function(value) {
return value !== value;
}
});
}
本文标签: javascriptWhy does IE give this error Object doesn39t support property or method isNaNStack Overflow
版权声明:本文标题:javascript - Why does IE give this error: Object doesn't support property or method isNaN - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738554109a2097944.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
isNaN
method without calling it fromNumber
object:if (isNaN(...))
. – VisioN Commented Mar 20, 2014 at 15:58window.isNaN
andNumber.isNaN()
. I think the latter is an EcmaScript 6 feature. – Johan Commented Mar 20, 2014 at 15:59Number.isNaN
is a very new and still experimental feature of the next JavaScript spec. It is not supported at all in IE. You've likely confused it with the globalisNaN
function, which has support in all browsers. – ajp15243 Commented Mar 20, 2014 at 15:59