harry_ord Posted October 6, 2016 Share Posted October 6, 2016 HelloI 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 More sharing options...
Ingolme Posted October 6, 2016 Share Posted October 6, 2016 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 More sharing options...
harry_ord Posted October 7, 2016 Author Share Posted October 7, 2016 Here is the whole code, the scripst are at the end of the body.https://github.com/ashcrimson/codelco/blob/master/index.html Link to comment Share on other sites More sharing options...
dsonesuk Posted October 7, 2016 Share Posted October 7, 2016 (edited) 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 October 7, 2016 by dsonesuk Link to comment Share on other sites More sharing options...
harry_ord Posted October 7, 2016 Author Share Posted October 7, 2016 Sorry, my mistake, and thanks for the answer. I didn't know what the function preventDefault did. I took it off and now everything is A-OK. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now