4

我正在尝试在 google chrome 中使用 shadowbox 3.0.3

我正进入(状态:

镀铬

shadowbox.js:17 未捕获类型错误:无法读取未定义的属性“样式”

在火狐中

F 未定义 g.find=(function(){var aD=/((?:((?:(...()}};g.skin=k;T.Shadowbox=g})(window); shadowbox.js(第 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>

什么会导致这个?

4

2 回答 2

8

按照文档中的建议使用 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>
于 2011-02-01T05:30:29.543 回答
1

这只是一个猜测,但也许 Shadowbox.init() 应该在 $(function() ...) 之外,以便在窗口加载之前调用它。这就是他们网站上的示例所暗示的:http ://www.shadowbox-js.com/usage.html

于 2011-02-01T05:09:04.807 回答