1

I am using notepad for coding html. I was writing a code to download an image of a flower. I have done everything correctly. I used tag 'a' and also used the attributes href and download. But it is only opening the link not downloading it. here is the source code and output i am getting.

<!DOCTYPE HTML>

<html>

<title>first website</title>

<body text = 'white', bgcolor = 'orange'>

    <h2 align = 'center'>
  <!--here i am using tag a to open the wikipedia page of flowers when clicked on the image-->
    <a href = 'https://en.wikipedia.org/wiki/Flower' target = _blank><img src = 'https://www.gardeningknowhow.com/wp-content/uploads/2021/07/sulfur-cosmos-mexican-aster-flowers.jpg' height = 20% width = 10% alt = "Not found"></a><br><br><br>

<!--here i am using it for downloading the image when clicked on the link-->       
<a href = 'https://www.gardeningknowhow.com/wp-content/uploads/2021/07/sulfur-cosmos-mexican-aster-flowers.jpg' download>click here </a>to download the image above

This is the web page.

If you click in that flower image wikipedia page of flowers will appear. And if you click that link, the above image of flower will download. That is what I intended to do. It is opening the wikipedia page when clicked on the image, But it is not downloading when clicked on the link. instead it is showing like this.

this is what it is showing.

It is not downloading. Instead it is just showing like this. could anyone tell me what is the problem here and how to solve it.

1 Answers1

0

The image should be same origin. if its on different origin the download link may not work as it work as a navigating link rather then a downloading link. it is because some browsers dont work cross download image.