View Full Version : Auto click link on page load

03-18-2007, 08:04 PM
I am currently using this script to display images:


I need help.. Basically when a user clicks a link on a different page, I want the thumbnail page to load with the correct image automatically displayed. Does anyone have any ideas?

Any help would be greatly appreciated.


03-19-2007, 04:21 AM
Just to be clear here, which is the correct image? If it varies, you will need to use either javascript or server side code to pass that information to the page. However, if it just the starting image, you can put that data and/or anything you like in here (from the demo):

<div id="loadarea" style="width: 500px">
This DIV will show my enlarged images!

Just replace the green part with whatever you'd like to be there when the page loads. In fact, using this method you could conceivably make up one page for each 'correct image' if there is more than one and simply link to that page.

03-19-2007, 07:00 PM
It will vary, there are multiple links on other pages that need to open to specific images upon loading.

03-19-2007, 07:25 PM
More questions:

Are you using captions?

Do you have PHP or some server side language available?

If you do, are you already passing information in a query?

If you have a server side language available, do you know how to use it?

03-19-2007, 07:32 PM
I am currently using PHP, but only to include files (header, footer, nav, etc). I can work with PHP code, but I am definately not at the point of creating it on my own.

What do you mean by captions?

03-19-2007, 10:19 PM
Well the script that you are talking about has optional captions (text) for under the enlarged image, I was wondering if you were using those. It would be easier if you were not but, not that big of a deal either way. Also, it would be good to know if you want the larger image linked or not.

Now, using PHP you could pass a query or perhaps even a post value to your page telling it which image to load. I don't know the syntax with PHP but for sending a value it would be (for a query):

<a href="gallery.php?photo=image1">Gallery</a>

That would send a query string to the gallery.php page. Using it is what I am not real clear on, it would be something like so:

<div id="loadarea" style="width: 500px">
<img src="<? get photo ?>.jpg" border="0">

This would make image1.jpg be the src for the image tag. From what I understand, you can also send the value post which means that it would not appear in the URL but, I have no idea how to do that.

If you are using PHP and especially if you are already passing post or query values, this would be the way to go. If this is too much for you (it is for me though help can probably be found in the PHP forum), a javascript method is available but it requires the query in the URL and if you are already doing any of that in PHP, care will need to be taken so as not to conflict with that. I'll work up the details of the javascript method for you if you want to go that route. It would help me to know about the captions and links for the larger images though.

03-20-2007, 12:33 AM
I think I understand (at least partially) what you mean with the PHP and I will certainly give it a try.

As for the captions, yes I am using them. However, I changed it so it is the name attribute which defines the caption rather than the title (I didn't like seeing a bunch of html pop up when hovering over a link). And finally, none of the images themselves are linked. If I needed a link I added it into the caption.

I am going to play around with the PHP you suggested and see what I can come up with. I will let you know how it goes in the next few days.

If the javascript method is not reasonably simple please don't feel obligated to spend all your time on it. I certainly appreciate your help, but I wouldn't feel right asking so much of you (especially for free!) =)

03-20-2007, 06:09 AM
Just wanted to let you know.. I did away with the javascript all together. I decided to just put the information (image & caption) into variables. Then I set all the links to 'www.site.com/path.php?linkname' as you suggested and displayed content based on the current url.

So every thing's much more flexible and easier to work with now. Thank you so much for your help! I don't know why I wasn't able to come up with that on my own lol.. =)