javascript - 暗箱 3.0.3

标签 javascript jquery shadowbox

我正在尝试在谷歌浏览器中使用 shadowbox 3.0.3

我得到:

在 Chrome 中

shadowbox.js:17 Uncaught TypeError: Cannot read property 'style' of undefined

在火狐中

F is undefined g.find=(function(){var aD=/((?:((?:(...()}};g.skin=k;T.Shadowbox=g})(window); shadowbox.js (line 17)

似乎在 IE 中工作正常

我的代码如下:

<!doctype html>
<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script>
    <script src="shadowbox.js"></script>
    <link href="shadowbox.css" rel="stylesheet"/>
    <script>
        $(function() {
            Shadowbox.init({skipSetup: true});

            // open a welcome message as soon as the window loads
            Shadowbox.open({
                content:    '<div id="welcome-msg">Welcome to my website!</div>',
                player:     "html",
                title:      "Welcome",
                height:     350,
                width:      350
            });
        })
    </script>
</head>
<body>

</body>
</html>

是什么原因造成的?

最佳答案

使用 docs 中建议的 window.load 方法:

<script type="text/javascript">
Shadowbox.init({
    skipSetup: true
});

$(window).load(function() {

    // open a welcome message as soon as the window loads
    Shadowbox.open({
        content:    '<div id="welcome-msg">Welcome to my website!</div>',
        player:     "html",
        title:      "Welcome",
        height:     350,
        width:      350
    });

});
</script>

关于javascript - 暗箱 3.0.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4858429/

相关文章:

javascript - 使用 jQuery() 添加元素

javascript - Meteor 如何访问服务器端和客户端的 Facebook Graph Api

javascript - Angular 7 : How to access/send only body part of HTTP Response from test case

javascript - jQuery Draggable with Bootstrap Tooltip TypeError : e. $element 为 null

javascript - 父子孙子复选框

jQuery - 触发器 ('click' ) 在 IE 中不工作 - 对象不支持此属性或方法

javascript - 从 javascript 函数打开 Shadowbox

jquery - 单击编辑按钮时显示的文本框

javascript - CSS 菜单未居中; javascript 不适用?

jquery - 在 Prettyphoto.js 或 Fancybox 中...如何在标题中添加链接