2012-12-17 83 views
0

我想在彈出窗口中加載html頁面。我做了一些谷歌,發現jquery colorbox。他們給出的例子使用anchor tag,但我想加載彈出按鈕點擊。jquery colorbox加載頁面彈出按鈕點擊

實例給出了顏色框

<a class='iframe' href="http://wikipedia.com">Outside Webpage (Iframe)</a> 

$(document).ready(function(){ 
    $(".iframe").colorbox({iframe:true, width:"80%", height:"80%"}); 
}); 

在顏色框它們加載外部頁面上鍊接的點擊彈出窗口的上面的例子,但我想這樣做,就按一下按鈕。

回答

1

嘗試:

<input type="button" id="yourButtonId" value="Load Page" /> 

$(document).ready(function(){ 
    $("#yourButtonId").on("click", function() { 
    $.fn.colorbox({iframe:true, width:"80%", height:"80%"}); 
    //or 
    $(".iframe").colorbox({iframe:true, width:"80%", height:"80%"}); 
    });  
}); 
+0

jQuery.fn.colorbox({iframe:tru e,寬度:「80%」,身高:「80%」})爲我工作 –

0

通過將顏色框在$(document).ready(function(){,被在網頁加載時創建的彈出窗口。

click事件簡單地綁定到按鈕:

$(document).ready(function(){ 
    $('#yourButtonId').click(function() { 
     $(".iframe").colorbox({iframe:true, width:"80%", height:"80%"}); 
    } 
}); 
0

綁定驗證碼按鈕點擊:

$(".iframe").colorbox({open:true, iframe:true, width:"80%", height:"80%"}); 

$(".iframe") - 必須有href標籤

open:true - 將打開顏色框後按鈕點擊

相關問題