c11ada
c11ada

Reputation: 4334

ASP.net and javascript automatically open lightbox

Im trying to add a light box which automatically opens up when someone visits my homepage. something similar to

http://directorsof.com/

any idea on how I can do this.

Upvotes: 0

Views: 1698

Answers (3)

Simon
Simon

Reputation: 2830

You can add the following to your home page

window.onload = function() {
     //Open your lightbox here
};

Or you can use Jquery all together with something like...

$(function(){
   $(body).load(function(){
      // Open your lightbox here
   });
});

both of the above will fire the lightbox once the page is loaded. Its probably better to use the jquery example as this will ensure that the DOM is ready.

Upvotes: 0

Mathias Florin
Mathias Florin

Reputation: 88

You can use for example colorbox to get a lightbox that opens after the page is loaded. Download colorbox from here: http://colorpowered.com/colorbox/latest, extract the file and modify the index.html file in the example1 folder.

Replace:

$("a[rel='example1']").colorbox();

with

$("a[rel='example1']").colorbox({open:true});

Open the index.html file in your browser to see the lightbox coming up directly.

Upvotes: 1

Syed Hussim
Syed Hussim

Reputation: 760

are you using a master page?You need to place 2 divs in your file. One that has a fixed position or absolute and dimmer the background, and another div that displays the content.

Check this link out, it is a web messagebox but it will do what you want using a template approach.

http://www.snippetbank.net/detail/snippetdetail/9-aspcsharp/3-filemanipulation/404-Web-MessageBox.html

Upvotes: 1

Related Questions