0

我正在尝试从 asp.net 网络表单上的单选按钮 onclick 事件中打开 Shadowbox,但没有成功。我最初使用按钮单击打开它,效果很好,但现在需要确保它在选择单选按钮选项时发生。然后我尝试单击 javascript (button.click()) 中的按钮,但这仅适用于 IE 和较新版本的 firefox。所以我选择使用 Shadowbox.open,但它会引起一些问题。这是我的代码:

if (yes.checked == true)
    {            
        var url = 'http://localhost:52963/items.aspx';
        Shadowbox.open( { content:    url, 
                        type:        "iframe", 
                        title:         "sbTitle ", 
                        options:   {   initialHeight:350, 
                                        initialWidth:450, 
                                        loadingImage:"loading.gif", 
                                        handleUnsupported:  'link' 
                                    } 
                     }); 
    }

这似乎只是显示了覆盖,但没有打开其中的网页。有人知道我要去哪里错了吗?

4

2 回答 2

2

显然我需要添加一个播放器和一个类型。所以修改后的代码是这样的:

Shadowbox.open( { content:    url, 
                    type:        "iframe", 
                    player:      "iframe",
                    title:         "sbTitle ", 
                    options:   {   initialHeight:350, 
                                    initialWidth:450, 
                                    loadingImage:"loading.gif", 
                                    handleUnsupported:  'link' 
                                } 
                 }); 
于 2011-07-05T08:16:44.547 回答
1

我遇到了很多麻烦,我尝试使用 jquery 中的 .trigger('click') 触发点击,但这在 chrome 中不起作用(在 firefox 中起作用)

原来答案很简单,类似于 e-on 答案,但拨号。

您的图像在普通的影子库中

<div class="gallery">
  <a  href="/img1.jpg" rel="shadowbox[gallery1]" >
    <img id="Image0" src="/img1.jpg" />
  </a>
  <a  href="/img2.jpg" rel="shadowbox[gallery1]" >
    <img id="Image1" src="/img2.jpg" />
  </a>
</div>

然后你的可点击链接

<a href="#" class="galleryLauncher" gallery="gallery1">Click to view all images</a>

我在 document.ready 调用中通过 jquery 连接了可点击的链接

$('.galleryLauncher').click(function () {

 //gallery to launch
    var id = $(this).attr('gallery');

 //get the first item out of the cache
    var content = Shadowbox.cache[1].content;

 //default options object
    var options = {}; 

 //now we can open it
    Shadowbox.open({
        content: content,
        player: "img",
        gallery: id,
        options: options
    });

    return false;
});
于 2011-11-29T14:12:07.463 回答