开发者

How to call jQuery colorbox with javascript onClick event instead of a link?

I want to call colorbox using javascript r开发者_运维问答ather than a href link?

anyone know how I can do this?

thanks.


The previous examples didn't work for me, but using the same idea, this does work:

<script>
function lightbox(){    
  $.colorbox({width:"80%", height:"80%", iframe:true, href:"/pagetoopen.html"});
}
</script>

<input type="button" value="open the box" onClick="lightbox()"/>


This is off the top of my head. But I believe you could do something like this:

<script type="text/javascript">
function call_cbox()
{
   jQuery.colorbox({html:'<p>Hi There I was instantiated onclick!</p>'});
}
</script>
<a href="#" onclick="call_cbox(); return false;">Give me a colorbox... NOW! And don't forget the color.</a>


A mix of the two answers above worked for me:

<script>
function call_cbox()
{
jQuery().colorbox({width:"900px", height:"600px", iframe:true, href:"/newsletter.html"});
}
</script>


$("tr").click(function () { 

    $.colorbox({width:"900px", height:"600px", iframe:true, href:"http://www.google.com"});

});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜