Hello!
How to open a link in another page created? for example.
<a href="" ><img src=""></a> <----- this image, to open in this -----> page. (this page have other design)
Thanks in advance!

Recommended Answers

All 4 Replies

Try this,

<a href="page.html"><img src="img_to_the_path" alt="image_description"/></a>

@cereal. thanks for your answer but this is not what im looking for.
I want that my photo (for example) open in another .html page (designed) with another structure.
@lau 1. thanks for ur answer, this is not what im looking for.

Hmm, I'm not sure I've understood your request.

Let's try: you have to define the image in the destination page, which can be done with a static or a dinamic approach.

When using a static method just create the page that will show a pre-defined image:

page.photo01.html

And point the browser to that specific page.

When using a dynamic method you create a container, a page that can elaborate and display the contents accordingly with the sent input.

The input can be sent by using GET and POST methods, which are HTTP verbs to access web resources. Below I'm going to show you a simple GET request approach:

You have to set a query string to the opening link so you can send the file name, for example:

<a href="page.php?img=photo01.jpg">
    <img src="/images/photo01.jpg">
</a>

Note page.php?img=photo01.jpg in the href attribute, you have to use a PHP file (or another server side scripting language), because you need to access the query string parameters.

So, in the page.php file you write something like this:

<?php

    $img   = array_key_exists('img', $_GET) ? basename($_GET['img']) : FALSE;

    # web path, used to display the file in the browser
    $path  = '/images/';
    $image = $path . $img;
?>
<!DOCTYPE>
<html>
...

<!-- display image here -->
<?php
    # display the image
    if($img) echo "<img src=\"{$image}\">";

    # default image (not required)
    else echo "<img src=\"/images/default.jpg\">";
?>

If you don't want to use server side languages, you can go with Javascript and read the query string from there. It's up to you.

If this still does not answer to your question, please add an extended example and information.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.