最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why isn't my Bootstrap modal window working in Opera? - Stack Overflow

programmeradmin3浏览0评论

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 badges
Add a ment  | 

2 Answers 2

Reset to default 7

This 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

发布评论

评论列表(0)

  1. 暂无评论