IE7 和 IE8 JS 对 Math.floor 的支持(或其他方法?)
我已经围绕这个主题研究了相当长一段时间,但我无法找出哪种方法或代码导致我在 IE7 和 IE8 上出现问题 - 它在 IE9、Chrome 和 FF 中工作正常。使用 IE9 的 F12 工具进行调试,当运行 IE7 或 IE8 模式时,javascript 会停在这一行,并出现错误 object does not support this property or method
:
pmt = (Math.floor((princ*intRate)/(1-Math.pow(1+intRate,(-1*months)))*100)/100).toFixed(2);
The script is located inline, not via a linked file 。
pmt
变量在此之前没有声明,它似乎表明该变量是问题所在。脚本会从之前声明的变量中受益吗?
提前致谢。
回答:
根据下面 Cory 的评论,问题不是由于任何特定方法造成的,而只是我未能在 pmt
变量之前添加 var
声明。
现在一切都已排序 - 谢谢
I've researched around this subject for quite some time but I can't find out which method or code is causing me problems with IE7 and IE8 - it works fine in IE9, Chrome and FF. Using IE9's F12 tools to debug, the javascript stops at this line with the error object doesn't support this property or method
when running IE7 or IE8 mode:
pmt = (Math.floor((princ*intRate)/(1-Math.pow(1+intRate,(-1*months)))*100)/100).toFixed(2);
The script is located inline, not via a linked file.
The pmt
variable is not declared prior to this, and it seems to point to the variable as the problem. Would the script benefit from the variable being declared earlier?
Thanks in advance.
ANSWER:
As per the comment by Cory below, the problem wasn't due to any specific method, but simply my failure to add the var
declaration before the pmt
variable.
All sorted now - thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为这是 math.floor 或 IE 的问题,看看这个小提琴: http://jsfiddle.net/ 4ULQL/2
可能是您传递了错误的参数,并且表达式的计算结果不正确,因此出现错误。
I dont think its a problem with math.floor or IE take a look at this fiddle: http://jsfiddle.net/4ULQL/2
May be you are passing in the wrong parameters and the expression is evaluating to something incorrect and hence the error.