问题
How can I show Colorbox on page load without event binding? In a more simple term I would like the Colorbox to load immediately on page load.
this is the Colorbox which I am currently using http://colorpowered.com/colorbox/
回答1:
You need to pass the open:true
key/value set to the constructor if you want it to open without user interaction:
$("selector").colorbox({ other_key:other_value, open: true});
However, it still binds to events if you were to close the box and try to reopen it.
回答2:
Have you tried:
$(document).ready(function(){
$.fn.colorbox();
}
That is, if you make it:
$(document).ready(function(){
alert('page loaded');
}
Then the alert will popup when the page has finished loading. So it's a matter of just replacing with the call that pops up the colorbox, which seems the one above (haven't tried though).
来源:https://stackoverflow.com/questions/1975170/jquery-colorbox