Link to home
Create AccountLog in
Avatar of Pete C
Pete CFlag for United States of America

asked on

How do you incorporate file links that do not open in the same window

I have a question about how best to incorporate links with respect to a list of files that a user has downloaded. e.g. if the user clicks on a link, it opens the file in the browser window (i.e. such that it replaces the original content). To return to the original content, the user then needs to press the browser back button (which is not the desired action).


I am curious as to how you typically handle this.  Do you set the target to '_blank' such that the file opens in another browser window or is there another way to approach it.  I appreciate your thoughts.


 <a href="filepath" target="_blank">filename</a>



ASKER CERTIFIED SOLUTION
Avatar of Paul Sauvé
Paul Sauvé
Flag of Canada image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account

As you mentioned, adding target="_blank"to the link will open the file in a new browser tab or window.


If you want more control over the behavior, you can use JavaScript to open the link in a new tab or window.


example:

<a href="filepath" onclick="window.open(this.href, '_blank'); return false;">filename</a>

Open in new window