1

I have an <a> tag on the page like below:

<a href="/-/media/Wallpapers/wallpaper_nokia.jpg" download="">Download Wallpaper</a>

When the user clicks on the link the save as button opens up for the user to save the image. What I want to do is to redirect user to the home page after user clicks on the save button.

Is there any way to achieve this in javascript?

R3tep
  • 12,512
  • 10
  • 48
  • 75
Milad
  • 552
  • 1
  • 4
  • 20

1 Answers1

0

Yes there is:

// similar behavior as an HTTP redirect
window.location.replace("http://stackoverflow.com");

// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";
Korovjov
  • 503
  • 5
  • 17