admin管理员组文章数量:1315221
I have a modal login window set up using the Twitter Bootstrap framework, exactly as described at .html#modals (using the Markup method and using their demo modal window as a starting point). It works wonderfully on multiple browsers (which is one of the great reasons to use Bootstrap in the first place).
However, when I test my page in Opera, the modal window is not working. The page fades out like it should, but the window does not appear. Why?
Using: Bootstrap v2.0.4, Opera 12
I have a modal login window set up using the Twitter Bootstrap framework, exactly as described at http://twitter.github./bootstrap/javascript.html#modals (using the Markup method and using their demo modal window as a starting point). It works wonderfully on multiple browsers (which is one of the great reasons to use Bootstrap in the first place).
However, when I test my page in Opera, the modal window is not working. The page fades out like it should, but the window does not appear. Why?
Using: Bootstrap v2.0.4, Opera 12
Share Improve this question edited Jul 21, 2012 at 21:45 merv 77.1k17 gold badges214 silver badges277 bronze badges asked Jul 21, 2012 at 5:58 shisershiser 2621 gold badge3 silver badges13 bronze badges2 Answers
Reset to default 7This is a known bug in Bootstrap, and I'm sure a fix is in the works, but for those of you who can't wait, or can't just change framework versions willy-nilly, here's a nice fix: The problem is due to the "fade" class used in the typical markup for the modal window:
<div id="myModal" class="modal hide fade in">
This fade
class provides the nice animation for the appearance/dismissal of the modal window. And it's apparently broken in Opera 12.
While removing the fade
class will make it work, there's no reason to deprive other browser users, so you can utilize this handy snippet of Javascript:
<script type="text/javascript">
$(document).ready(function()
{
if (navigator.appName == "Opera")
{
$('#myModal').removeClass('fade');
}
});
</script>
This will remove the fade
class for Opera, but retain it for other browsers. Note that this will disable it for Opera altogether, including people on older versions. If you're interested in narrowing the scope of the fix, you can test navigator.userAgent
to determine the version (the User Agent header for Opera 12 is Opera/9.80 (Windows NT 6.1; WOW64; U; en) Presto/2.10.289 Version/12.00
on my puter, but since that won't be universal you'd just want to check for the presence of the 12.00
at the end of the string. Maybe someone industrious and less sleepy can add a souped up version in the ments :)
i would suggest using modernizr and something like
$('.no-csstransforms3d .fade').removeClass('fade');
rather
that way if for instance opera release opera 13 the code above wont work :P
could do .no-csstransforms3d .modal.fade
本文标签: javascriptWhy isn39t my Bootstrap modal window working in OperaStack Overflow
版权声明:本文标题:javascript - Why isn't my Bootstrap modal window working in Opera? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741982325a2408472.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论