我正在尝试在谷歌浏览器中使用 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/