简体   繁体   English

与数学相关的 Javascript 适用于除 Internet Explorer 之外的所有浏览器

[英]Math-related Javascript working in all browsers except Internet Explorer

I'm having issues with a custom bit of JS running in all browsers but IE10 (probably not working in previous versions either).我在除 IE10 之外的所有浏览器中运行自定义位 JS 时遇到问题(可能也不适用于以前的版本)。 I have run the debug and fixed the "errors "it threw up but seeing they had no effect on fixing the issue I reverted to the old version.我已经运行调试并修复了它抛出的“错误”,但看到它们对修复我恢复到旧版本的问题没有影响。

Tested in Firefox, Chrome, Opera and Safari (Most recent Windows versions) with no issues, it's just IE screwing it over, if anyone could give suggestions I'd be very appreciative, thanks.在 Firefox、Chrome、Opera 和 Safari(最新的 Windows 版本)中测试没有问题,只是 IE 把它搞砸了,如果有人能提供建议,我将非常感激,谢谢。

Edit: Let me try this again, seems people think I haven't spent time researching this.编辑:让我再试一次,似乎人们认为我没有花时间研究这个。

The code (removed all styling):代码(删除所有样式):

<form>
<div>Crates: <output name="crates">0</output><br />
Skates: <output name="skates">0</output></div>
<div>
    <label for="desks">Desks</label><br />
    <input type="number" name="desks" value="0" />
</div>
<div>
    <label for="pedestals">Pedestals</label><br />
    <input type="number" name="pedestals" value="0" />
</div>
<div>
    <label for="drawers">Individual Drawers</label><br />
    <input type="number" name="drawers" value="0" />
</div>
<div>
    <label for="credenzas">Credenzas</label><br />
    <input type="number" name="credenzas" value="0" />
</div>
<div>
    <label for="cabinets">Storage Cabinets</label><br />
    <input type="number" name="cabinets" value="0" />
</div>
<div>
    <label for="shelves">Shelves</label><br />
    <input type="number" name="shelves" value="0" />
</div>
<div>
    <label for="smbookcases">Small Bookcases</label><br />
    <input type="number" name="smbookcases" value="0" />
</div>
<div>
    <label for="lgbookcases">Large Bookcases</label><br />
    <input type="number" name="lgbookcases" value="0" />
</div>
<div style="clear:both;"></div>
<input type="button" value="Calculate" onclick="crates.value=((2)*parseInt(desks.value))+parseInt(pedestals.value)+parseInt(drawers.value)+((6)*parseInt(credenzas.value))+((6)*parseInt(cabinets.value))+parseInt(shelves.value)+((3)*parseInt(smbookcases.value))+((6)*parseInt(lgbookcases.value)); skates.value=Math.floor((((2)*parseInt(desks.value))+parseInt(pedestals.value)+parseInt(drawers.value)+((6)*parseInt(credenzas.value))+((6)*parseInt(cabinets.value))+parseInt(shelves.value)+((3)*parseInt(smbookcases.value))+((6)*parseInt(lgbookcases.value)))/3-0.1)+1">

In IE, clicking "Calculate" does not appear to do anything, while in the other browsers mentioned it seems to work 100% right (unless I'm missing something).在 IE 中,单击“计算”似乎没有做任何事情,而在提到的其他浏览器中,它似乎 100% 正确(除非我遗漏了一些东西)。 Apologies for the rookie post, usually I just Google-warrior through this but I haven't had much luck so far.为新秀帖子道歉,通常我只是通过这个谷歌战士,但到目前为止我没有太多运气。

The problem with your code is the use of the <output> tag for displaying your results.您的代码的问题是使用<output>标签来显示您的结果。 As per this page , this is not supported by Internet Explorer.根据此页面,Internet Explorer 不支持此功能。

Use a <span> to display the results by using code similar to the following:使用<span>通过使用类似于以下的代码来显示结果:

document.getElementById('skates').innerHTML = ....;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM