1
I am trying to use the . load function of jquery, replacing the .click. because the intention is for the lightbox to open when loading the page and not clicking.
JS TO OPEN THE MODAL WINDOW BY CLICKING ON A LINK
$(document).ready(function(){
$("a[rel=modal]").click( function(ev){
ev.preventDefault();
var id = $(this).attr("href");
var alturaTela = $(document).height();
var larguraTela = $(window).width();
//colocando o fundo preto
$('#mascara').css({'width':larguraTela,'height':alturaTela});
$('#mascara').fadeIn(1000);
$('#mascara').fadeTo("slow",0.8);
var left = ($(window).width() /2) - ( $(id).width() / 2 );
var top = ($(window).height() / 3) - ( $(id).height() / 3 );
$(id).css({'top':top,'left':left});
$(id).show();
});
$("#mascara").load( function(){
$(this).hide();
$(".janelao").hide();
});
$('.fechar').click(function(ev){
ev.preventDefault();
$("#mascara").hide();
$(".window").hide();
});
});
JS TO OPEN THE MODAL WINDOW WITH PAGE LOADING
In this part I changed the $("a[rel=modal]"). click for $(window). load and IT WORKED! But it only opens the black background and not the div #janelao
$(document).ready(function(){
$(window).load( function(ev){
ev.preventDefault();
Hence $("#mascara"). click( Function(){ tried to insert . load and $(window). load instead of . click and . show instead of . Hide and DID NOT work
$("#mascara").load( function(){
$(this).show();
$(".janelao").show();
});
So my problem is carrying the janelao div that doesn’t carry, only carries the black background
Thank you for your reply, Felipe. Finally I used this solution http://wbruno.com.br/jquery/abrir-modal-tuto-maujor-automaticamente-ao-load-pagina-jquery/
– user49915
thanks friend.. that’s right.. this tip helped me a lot
– user38808