I want to call colorbox using javascript rather 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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With