简体   繁体   English

JQuery DatePicker for input type=date IE11 错误:对象不支持属性或方法交换

[英]JQuery DatePicker for input type=date IE11 Error: Object doesn't support property or method swap

I am using the html5 tag:我正在使用 html5 标签:

<input type="date" name="date" id="date">

this works on phones en microsoft edge browser but not on internet explorer.这适用于手机和微软边缘浏览器,但不适用于 Internet Explorer。 to get it to work on IE11, I added the following:为了让它在 IE11 上工作,我添加了以下内容:

<script src="//cdn.jsdelivr.net/webshim/1.14.5/polyfiller.js"></script>
<script>
webshims.setOptions('forms-ext', {types: 'date'});
webshims.polyfill('forms forms-ext');
</script>

When I click on the calendar in IE11, I get the following error: Object doesn't support property or method swap.当我在 IE11 中单击日历时,出现以下错误:对象不支持属性或方法交换。

I am using the following JQuery sources:我正在使用以下 JQuery 源:

<script   src="https://code.jquery.com/jquery-2.2.2.min.js"></script> 
<script   src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script> 

This appears to be a bug in webshim.这似乎是 webshim 中的一个错误。 https://github.com/aFarkas/webshim/issues/560 states two possible workarounds https://github.com/aFarkas/webshim/issues/560陈述了两种可能的解决方法

  1. re-instate the swap function.重新设置交换功能。 I tested by putting it in a jquery-swap.js file, and included it after jquery.我通过将它放在 jquery-swap.js 文件中进行了测试,并将其包含在 jquery 之后。

jquery-swap.js: jquery-swap.js:

jQuery.swap = function( elem, options, callback, args ) {
  var ret, name, old = {};
  // Remember the old values, and insert the new ones



  for ( name in options ) {
        old[ name ] = elem.style[ name ];
        elem.style[ name ] = options[ name ];
  }

  ret = callback.apply( elem, args || [] );

  // Revert the old values
  for ( name in options ) {
          elem.style[ name ] = old[ name ];
  }
  return ret;
};

index.html索引.html

<script src="https://code.jquery.com/jquery-2.2.2.js"></script>
<script src="js/jquery-swap.js"></script>
  1. roll back jquery to 1.11.3将 jquery 回滚到 1.11.3

It would be nice if the dependencies were clearly stated.如果明确说明依赖关系就好了。

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

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