3
Load page only when image is loaded, as I do using JQuery
?
I tried some things but unsuccessfully so far, someone helps me...
I don’t have the only image id of the div q it is inside...
EDIT: I’m using a jquery plugin for background image, the backstrech and this background image is 2mb and it takes time to load, the code I use is this:
<script src="jquery.backstretch.min.js"></script>
<script>
$.backstretch("fundo.gif");
</script>
backstretch uses div with class backstretch
I tried from there several ways to do this guy:
<script>
$(".backstretch").load(function() {
$("#corpo").show();
});
</script>
and this:
<script>
$("img.backstretch").load(function() {
$("#corpo").show();
});
</script>
inform you a little bit more like your html snippet here to make it easier for us to help you
– Roger Barretto
put more information Rogerio, hope it helps...
– Alan PS
Do the following, make sure there are no errors happening in your javascript that is interrupting the execution of it. Then put a
alert
within the load functions and see if they are being called. Break at last make a test and call by the function$('#corpo').show();
and see if the result is as expected.– Roger Barretto
actually there is no error in the script, simply it works but the image loads after anyway...
– Alan PS
Next, put in your CSS, stating that the image and the #body start invisible (display:None / visibility:Hidden). Put a summary HTML page so I understand better :).
– Roger Barretto
Recalling that the
show
will only take effect if your element#corpo
be withdisplay: none
. If you’re withvisibility: hidden
- which means that it is invisible, but still occupies space on the page - theshow
does not affect it, it would be necessary to use.css("visibility", "visible")
in that case.– mgibsonbr