我正在尝试在Google Chrome中使用shadowbox 3.0.3
我得到了:
in chrome
shadowbox.js:17未捕获的TypeError:无法读取未定义的属性“样式”
在firefox中
F未定义 g.find =(function(){var aD = /((?:((?:( ...()}}; g.skin = k; T.Shadowbox = g})(窗口); 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>
会造成什么?
答案 0 :(得分: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>
答案 1 :(得分:1)
这只是一个猜测,但也许Shadowbox.init()应该超出$(function()...),以便在窗口加载之前调用它。这就是他们网站上的示例所暗示的内容:http://www.shadowbox-js.com/usage.html