View Full Version : Javascript On Load Issue?

06-16-2010, 01:28 AM
Good Afternoon all,

Currently I'm trying to manipulate the tutorial found here,
to better fit my needs.

I've got basically everything I need thus far, except for the fact I want it to load when the page loads and not when a link is clicked. It seems the part i have to edit is located here:

$(document).ready(function() {


I've tried to put the above into a function to call it on body onload, but it doesn't give me what i want.

Can anyone give me any advice on this?

06-16-2010, 03:13 AM
I havent tried it out, just wondering what would happen if you changed this part

.simple_overlay {

/* must be initially hidden */

/* place overlay on top of other elements */

/* styling */

border:1px solid #666;

/* CSS3 styling for latest browsers */
-moz-box-shadow:0 0 90px 5px #000;
-webkit-box-shadow: 0 0 90px #000;
the display:none can be changed to display: block; and i guess that would show the overlay on page load. Of course it wouldn't work to well if you have several overlay pictures on your page. I am just guessing so it might not work !

06-16-2010, 01:34 PM
$(document).ready is like onload. Except images might not be fully loaded yet. Try:

$(document).ready(function() {


That will activate the first a tag with a rel. If you have more than one, you may choose which one by using its zero based index. Like the second one would be eq(1), the third eq(2) and so on.

If you want to wait a little longer, but there is still no guarantee that your display none image will be loaded (this only matters if there are images in the overlay):

$(window).load(function() {


If you have just one, as azoomer says, it might work to just change the display property in the css to block as he suggests.