gpt4 book ai didi

javascript - Shadowbox - 如何切换或替换内容?如何关闭和打开另一个对话框?

转载 作者:搜寻专家 更新时间:2023-11-01 04:38:47 28 4
gpt4 key购买 nike

我尝试在多个场合使用 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>

问候,
编辑

最佳答案

抱歉,但我想我会转向 colorbox,因为它看起来更稳定:

$('#second-btn').live('click', function(e){
e.preventDefault();
$.colorbox({
onComplete: function(){
$('#cboxLoadedContent').append('second opened');
$('#cboxClose').attr('id', 'cboxClose_disabled');
},
html:'<p>Second <a id="first-btn" href="x">first</a></p>',
width: 500, height: 200
});
});

function showfirst(){
$.colorbox({
onLoad: function(){ $('#cboxClose_disabled').attr('id', 'cboxClose'); },
onComplete: function(){ $('#cboxLoadedContent').append('first opened') },
html:'<p>First <a id="second-btn" href="x">second</a></p>',
width: 500, height: 200
});
}

$('#first-btn').live('click', function(e){
e.preventDefault();
showfirst()
});

showfirst();

嘿,我是一个人说话吗?! XD

关于javascript - Shadowbox - 如何切换或替换内容?如何关闭和打开另一个对话框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8050250/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com