HTML5输入类型=数字Polyfill在IE10中不起作用

bru*_*eaf 6 html5 polyfills internet-explorer-10

我试图使用这个pollyfill:https://github.com/jonstipe/number-polyfill

但它在IE10中没有任何作用.也没有脚本错误.除了包含JS和CSS文件之外还有什么吗?

我将更进一步,并指出polyfill的官方演示甚至不能在Windows 8上的IE10中工作:http://jonstipe.github.io/number-polyfill/demo.html

Sam*_*son 3

问题从一开始就很明显:

i = document.createElement("input");
i.setAttribute("type", "number");
if (i.type === "text")
Run Code Online (Sandbox Code Playgroud)

Internet Explorer 10 中的结果i.type是“数字”,这意味着 Internet Explorer 10 实际上支持数字输入类型 - 通过查阅他们的文档进一步证实了这一点。您甚至可以通过尝试将字母放入数字输入来确认该功能已到位 - 当元素失去焦点时它们将被删除。

如果您希望此工具逐步增强 Internet Explorer 中此控件的界面,则需要使条件解析为 true。