?
Solved

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

Posted on 2008-10-17
10
Medium Priority
?
2,185 Views
Last Modified: 2012-05-05
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
Comment
Question by:mrcoulson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 19

Expert Comment

by:Albert Van Halen
ID: 22745351
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
 

Author Comment

by:mrcoulson
ID: 22759699
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
 

Author Comment

by:mrcoulson
ID: 22759818
Nevermind.  Got it.

<script type="text/javascript" src="jquery_lightbox/js/jquery.lightbox.packed.js?show_linkback=false"></script>
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mrcoulson
ID: 22759851
But now how do I make it load automatically?  
0
 
LVL 19

Expert Comment

by:Albert Van Halen
ID: 22760344
By specifiying the start option and set it to true.
IE $("a.lightbox").lightbox( { "start":true });
0
 

Author Comment

by:mrcoulson
ID: 22760678
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
 

Author Comment

by:mrcoulson
ID: 22760794
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
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 2000 total points
ID: 22760852
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
 

Author Comment

by:mrcoulson
ID: 22760902
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
 
LVL 19

Expert Comment

by:Albert Van Halen
ID: 22760917
You're welcom, glad I could help
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question