[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2200
  • Last Modified:

How can I make a Lightbox load with the page's onLoad?

I'm ready to hand in my web design title and go look for bricklaying jobs.  I need a Lightbox to load when the page loads.  I've tried adding the lightbox.js or some elements thereof to onLoad: no dice.  I've tried simulating a click of a link: no dice.  I simulate a link of a button with no problem, but that won't let me do the Lightbox.  How can I pass the rel attribute this way?

I'm ready to scream.
0
mrcoulson
Asked:
mrcoulson
  • 6
  • 4
1 Solution
 
Albert Van HalenAnalyst developerCommented:
There are a number of lightboxes available.
I use jQuery's balupton edition (http://plugins.jquery.com/project/jquerylightbox_bal) which has an autostart option.
0
 
mrcoulsonAuthor Commented:
This looks promising.  I don't really know two nothings 'bout jQuery, though.  I'm trying this out.  Now let's say that my employer doesn't want the cool "jQuery Lightbox..." text in the right-hand corner of the window.  How do I eliminate that?

Jeremy
0
 
mrcoulsonAuthor Commented:
Nevermind.  Got it.

<script type="text/javascript" src="jquery_lightbox/js/jquery.lightbox.packed.js?show_linkback=false"></script>
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
mrcoulsonAuthor Commented:
But now how do I make it load automatically?  
0
 
Albert Van HalenAnalyst developerCommented:
By specifiying the start option and set it to true.
IE $("a.lightbox").lightbox( { "start":true });
0
 
mrcoulsonAuthor Commented:
I guess this is where my understanding of jQuery falls apart.  Where does that code belong?

In good ol' JavaScript, I'd imagine doing something like that onLoad, like: <body onLoad="runTheFunctionThatLaunchesTheLightbox('theIdOfTheAnchorToBeSelectedForTheLightbox');">

Jeremy
0
 
mrcoulsonAuthor Commented:
Okay, I'm beginning to see a little bit of how this works.

$("a.lightbox").lightbox( { "start":true });

$ means it's jQuery.

a.lightbox means it's an anchor with rel="lightbox".

I'm not sure about .lightbox.

"start":true sets some property called start to true.

So, I'm guessing the middle .lightbox is a reference to my particular anchor.  Right?  Wrong?  Maybe?
0
 
Albert Van HalenAnalyst developerCommented:
You can put script just before the </body> ie
$(function() {
    $("a.lightbox").lightbox( { "start":true });
});

$(function() {}) is short-hand for DOM ready functionality

In this example the lightbox is bound to every A element with classname 'lightbox', and started directly.

Useful links : http://docs.jquery.com
<script type="text/javascript">
$(function() {
	$("a.lightbox").lightbox( { "start":true });
});
</script>

Open in new window

0
 
mrcoulsonAuthor Commented:
Hey!  500 points for you!

Thanks for the answer and thanks for helping me get started with jQuery.  This is pretty cool stuff and it will give me something new to try when I start my new job next week.  Thanks!!

Jeremy
0
 
Albert Van HalenAnalyst developerCommented:
You're welcom, glad I could help
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now