Code Road
Code Road

Reputation: 91

Need to click a link on body load

I have a domain www.example.com . I have created a subdirectory discount and it has a index.php file. What I want is that when a user mouses over www.example.com, along with the website this discount page also open up in lightbox. I know how to do this via prettyphoto(Lighbox open up when you click on discount link), but the problem is how to trigger this action on page load.

Upvotes: 1

Views: 1969

Answers (4)

Lee Price
Lee Price

Reputation: 5212

this triggers on document ready

$(document).ready(function()
                       {
                           //todo
                       });

Upvotes: 1

ComFreek
ComFreek

Reputation: 29434

You can use the onload event of the window object:

window.onload = function()
{
  // Show your lightbox!
}

You are already using jQuery, so you could write this, too:

$(document).ready(function()
{
  // Show your lightbox!
});

Upvotes: 0

scumah
scumah

Reputation: 6393

PrettyPhoto gives us the .open call, wich I believe can be used to directly open a modal box, with no need to click, like this:

$(document).ready(function()
{
  $.prettyPhoto.open('images/image.jpg','Title','Description');
});

Upvotes: 2

Sahil Muthoo
Sahil Muthoo

Reputation: 12506

Just trigger the click event in the ready handler. I've assumed the id of your link is #link.

$(document).ready(function() {
    $('#link').click();
});

Upvotes: 1

Related Questions