Shadowbox - 如何切换或替换内容?如何关闭和打开另一个对话框?
我尝试在多种场合使用 Shadowbox:有时我碰巧同时需要多个对话框。
在这个简单的示例中,我尝试关闭一个现有窗口并重新打开另一个窗口,但没有打开第二个窗口。我做错了什么?
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="shadowbox.css" type="text/css">
<style type="text/css" media="screen">
#sb-body, #sb-loading { background:#eee; }
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js"></script>
<script src="shadowbox.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
Shadowbox.init();
window.onload = function(){
Shadowbox.open({
content: 'First window. <a id="open-second" href="http://www.google.com">open another window</a>.',
player: "html"
});
$('#open-second').live('click', function(e){
e.preventDefault();
Shadowbox.close();
Shadowbox.open({
content: 'Second window.',
player: "html"
});
});
};
</script>
</head>
<body>blabla.</body>
</html>
问候,
阿迪特
I'm trying to use shadowbox in multiple occasions: sometimes I happen to need more than one dialog at the same time.
In this simple example I try to close one existing window and re-open another one but is not opening the second one. What I'm doing wrong?
<!DOCTYPE HTML>
<html>
<head>
<link rel="stylesheet" href="shadowbox.css" type="text/css">
<style type="text/css" media="screen">
#sb-body, #sb-loading { background:#eee; }
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js"></script>
<script src="shadowbox.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
Shadowbox.init();
window.onload = function(){
Shadowbox.open({
content: 'First window. <a id="open-second" href="http://www.google.com">open another window</a>.',
player: "html"
});
$('#open-second').live('click', function(e){
e.preventDefault();
Shadowbox.close();
Shadowbox.open({
content: 'Second window.',
player: "html"
});
});
};
</script>
</head>
<body>blabla.</body>
</html>
Regards,
Adit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
抱歉,但我想我会转向 colorbox,因为它看起来更稳定:
嘿,我是在一个人说话吗?! XD
Sorry 'bout this, but I think I'll move towards colorbox as it seems far more stable:
Hey, am I talking alone?! XD
这就是我要使用的;对此不满意:
- 我强迫一个广泛使用的插件执行一个简单的任务(关闭一个窗口并打开另一个窗口)
- 它需要覆盖每个shadowbox功能(现在仅实现播放器“html”)。
这里有一个完整的工作示例。
Here's what I'll use; not happy with this as:
- I'm forcing a widely used plugin doing a simple task (close a window and open another)
- it needs to override each shadowbox feature (now only player "html" is implemented).
Here a full working example.