Jump to content

Put a pdf on the server and make it accesible with <a> tag


harry_ord

Recommended Posts

Hello

I have a website and i want people to be able to read a pdf file on my server, so i put the file on a "files" folder and then i do this:

<a class="btn btn-info bases" style="position: absolute; left: 565px; top: 200px; padding-left: 122px;" href="archivos/Bases.pdf" >Ver bases</a>

If left-click on the hyper-link, the file doesn't open but, if i right click on the hyperlink and i choose "open link on a new tab", the file is opened correctly on the new tab.

How can i make the file accesible with just left-clicking?

Link to comment
Share on other sites

The only reason I could imagine a link not working is if there was some Javascript on the page preventing it from doing so.

 

If you could show an example page where the issue can be reproduced we could see it in context and find out where the problem is.

Link to comment
Share on other sites

What do you think preventDefault() does! Seeing that the default action of anchor link is to take you to the href url of file on a click event

$(document).on('click', 'a', function(event){
event.preventDefault();
$('html, body').animate({
scrollTop: $( $.attr(this, 'href') ).offset().top
}, 500);
});

You should be more specific on which anchor element to prevent it going to href url, NOT all anchor links which you have now.

Edited by dsonesuk
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...