Shadowbox

编程入门 行业动态 更新时间:2024-10-25 23:30:30
Shadowbox - 如何切换或替换内容?(Shadowbox - How to switch or replace content? How to close and open another dialog?)

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

最满意答案

对不起'回合,但我想我会走向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

Sorry 'bout this, but I think I'll move towards colorbox as it seems far more stable:

$('#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();

Hey, am I talking alone?! XD

更多推荐

本文发布于:2023-07-05 01:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1031243.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Shadowbox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!