2011-07-04 108 views
0

我想從asp.net web窗體上單選按鈕onclick事件中打開Shadowbox而沒有成功。我最初打開它時使用的按鈕點擊工作正常,但現在需要確保它發生在選擇單選按鈕選項時。然後我嘗試點擊javascript(button.click())中的按鈕,但只適用於IE和較新版本的Firefox。所以我選擇使用Shadowbox.open,但它會導致一些問題。這裏是我的代碼:從javascript函數打開Shadowbox

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' 
            } 
        }); 
    } 

這似乎只是調出覆蓋,但不打開其中的網頁。任何人都知道我要去哪裏錯了?

回答

2

顯然我需要添加一個球員以及一個類型。因此,修改後的代碼是這樣的:

Shadowbox.open({ content: url, 
        type:  "iframe", 
        player:  "iframe", 
        title:   "sbTitle ", 
        options: { initialHeight:350, 
            initialWidth:450, 
            loadingImage:"loading.gif", 
            handleUnsupported: 'link' 
           } 
       }); 
+0

值得一提的是,這個函數在單選按鈕組的onchange事件上,並且有Chrome的onchange事件問題,所以沒有幫助這個問題。一旦我改爲onclick事件,那麼問題就解決了。 –

1

我有很多的麻煩,這一點,我嘗試使用.trigger從jQuery的(「點擊」)發射的點擊,但在鉻(在Firefox工作)沒有工作

原來,答案非常簡單,類似於電子答案,但撥打電話。

你的圖像是在一個正常的太極拳畫廊

<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> 

我有線了通過jQuery的可點擊的鏈接中的document.ready通話

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