kam_685 kam_685 - 4 months ago 15
Ajax Question

open pop-up box when open page

i have code bu ajax like this :

$("document").ready(function (){

$(".open_popup").colorbox({width:"580px", inline:true, href:"#subscribe_popup"});

});


this is pop up box, i need when open page open this pop up, to open this pop up i use this code

<a href="#" class="open_popup">Click here to open the popup</a>


how can open pop-up onload tag on body.

Answer

If you are trying to load inline content (#subscribe_popup), you should use html property, not href.

From Colorbox documentation:

$.colorbox({html:$('#subscribe_popup')})

As the other answer suggests, use it inside $(window).load()

$(window).load(function(){
    $.colorbox({html:$('#subscribe_popup')})
});