Modal not opening in IE

て烟熏妆下的殇ゞ 提交于 2019-11-27 09:14:43

IE does not support the "fade" class for modals, by taking out fade i lost the animation, but the modal displays in all 3 browsers now. I found the answer here: https://github.com/twitter/bootstrap/issues/3672

@scalen121 's answer worked for me (the fade animation causes it to break). However, I had a problem with the suggested code fixes..

If you want to remove the fade animation just for IE (it doesn't seem to work even on IE11) but leave it for other browsers, then you can add the snippet:

$(function () {
    var isIE = window.ActiveXObject || "ActiveXObject" in window;
    if (isIE) {
        $('.modal').removeClass('fade');
    }
});

Note that the above IE check is not the same as doing the old: $.browser.msie, which returns undefined on IE11 (tested with jQuery 1.8.3 and 1.7.2).

IE so sad. But you can add tag

<meta http-equiv="X-UA-Compatible" content="IE=edge">

on after <html> tag. It's will work. And you should include only bootstrap.min.js. It's enough.

Here is another solution without modifying initial bootstrap layout and code:

var $modalWrapper = $('#modalWrapper');
$modalWrapper.on('show.bs.modal', function () {
    $modalWrapper.toggleClass('in', true);
});
$modalWrapper.on('hidden.bs.modal', function () {
    $('.modal-backdrop.fade').remove();
});

You can include transition.js file instead of removing the fade class. This works fine for me with fade effect in IE10

I was also having same problem today. And after removing the fade class didn't work for me even. Thus, I further inspected and found an issue there. The bootstrap isn't able to add element.style{display:block;padding-right:12px;} (here element means .modal) in IE. And after adding the following css worked fine:

.modal-open .modal {
  display: block;
}

Note: I didn't need to remove the fade class. And the animation is also working fine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!