4

Google Chrome でシャドウボックス 3.0.3 を使用しようとしています

私は得ています:

クロームで

shadowbox.js:17 Uncaught TypeError: 未定義のプロパティ 'style' を読み取れません

ファイアフォックスで

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

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>
于 2011-02-01T05:30:29.543 に答える
1

これは単なる推測ですが、おそらく Shadowbox.init() は $(function() ...) の外に出て、ウィンドウがロードされる前に呼び出されるようにする必要があります。それは彼らのサイトの例が示唆していることです: http://www.shadowbox-js.com/usage.html

于 2011-02-01T05:09:04.807 に答える