|
Posted by shimmyshack on 03/20/07 10:21
On 20 Mar, 10:05, "ten" <ten@.com> wrote:
> I have a page with images and when you click on a thumb a larger image
> opens. When the larger image opens the previous thumbs are not on the page
> so it makes it a little awkward to navigate to the next image because I have
> to go back with my browser back button, and then from the thumb page I click
> on the next image for the larger image, then again the back button, etc..,
> etc..
>
> Is there a standard bit of code I can use to create previous and next links
> on the larger image page?
>
> thanks
you could script with javascript/php.
<a href="large.php?pic=duck.jpg title="large duck">
<img src="small_duck.jpg" alt="small duck" />
</a>
large.php
<?php
$pic = basename( $_GET['pic']);
$description = 'Large image of ' . $pic;
$previous = ($_SERVER['HTTP_REFERER']!='')
?
$_SERVER['HTTP_REFERER']
:
'javascript:history(-1);';
?>
<html>
<head>
<title><?php echo $description; ?></title>
</head>
<body>
<a href="<?php echo $previous; ?>" title="<?php echo $description; ?
>">
<img src="/images/large/<?php echo $pic; ?>" />
</a>
</body></html>
however if you open the larger image in a new window (or tab if your
user prevents new windows) - which is obviously discouraged, you just
need to use the target attribute of the a tag.
please see the <a href="large_image.jpg" target="bigger">large image
of a duck</a> for more detail
note though, the target attribute is not allowed with xhtml IIRC.
Navigation:
[Reply to this message]
|