【发布时间】:2010-12-10 04:32:28
【问题描述】:
我想使用 javascript 而不是 href 链接调用颜色框?
有人知道我该怎么做吗?
谢谢。
【问题讨论】:
标签: javascript jquery colorbox
我想使用 javascript 而不是 href 链接调用颜色框?
有人知道我该怎么做吗?
谢谢。
【问题讨论】:
标签: javascript jquery colorbox
前面的例子对我不起作用,但使用相同的想法,这确实有效:
<script>
function lightbox(){
$.colorbox({width:"80%", height:"80%", iframe:true, href:"/pagetoopen.html"});
}
</script>
<input type="button" value="open the box" onClick="lightbox()"/>
【讨论】:
这不是我的想法。但我相信你可以这样做:
<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>
【讨论】:
以上两个答案的混合对我有用:
<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"});
});
【讨论】: