2011-02-01 48 views
4

我試圖用太極拳3.0.3谷歌瀏覽器太極拳3.0.3

我越來越:

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

在Firefox

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> 

會是什麼造成的?

回答

8

使用window.load方法,建議在docs

<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> 
1

這只是一個猜測,但也許Shadowbox.init()應該超出$(function()...),以便在窗口加載之前調用它。那是什麼在其網站上的例子表明:http://www.shadowbox-js.com/usage.html