0

I prepared a small site which download photos from instagram. I found a jpg link in the source code, but i don't know how to translate it to link for download.

I also want to download link immediately after finding (not a click event). My current code:

    function link()
    {
        for (var i= licznik;i<data.length;i++) //data is a response text(XMLHTTP)
            {
                kod=kod+data[i];
                if(data[i+2]== " ")
                    {
                    console.log(kod); //it works(returning correct url for example: https://something.jpg)
                    Pobierz(); // this function has to call a download
                    break;
                    }
            }
        console.log(kod);
    }
    function Pobierz()
    {
        var link;
        link.href = string(kod); // error
        link.click(); // i don't want onclick - it has to be downloaded when function is called
        }
GhostCat
  • 137,827
  • 25
  • 176
  • 248
  • 4
    Possible duplicate of [Download image with JavaScript](https://stackoverflow.com/questions/17311645/download-image-with-javascript) – etarhan Sep 13 '18 at 08:32
  • Welcome to Stack Overflow! Other users marked your question for low quality and need for improvement. I re-worded/formatted your input to make it easier to read/understand. Please review my changes to ensure they reflect your intentions. But I think your question is still not answerable. **You** should [edit] your question now, to add missing details (see [mcve] ). Feel free to drop me a comment in case you have further questions or feedback for me. – GhostCat Sep 13 '18 at 11:26

0 Answers0