Solved

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

Posted on 2008-10-17
10
2,181 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
  • 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

777 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