Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Occasionally, you may want to give users the ability to download a file or resource on your site and most, of the time you can do this by simply using a basic link. Now, to show you how this works, we're going to use the resource.htm file, and you can find that in 04_03. Now you're also going to notice in this directory I have a folder called _assets, and inside that I have two files here. I have the PDF file and then I have the same PDF file that's zipped up. So most of the time when you link to a PDF file, people have the ability to look at that within their browser. But perhaps you want to give them the ability to also download this PDF file, so they can print about later on or do something else with it.
If a browser cannot render that particular resource within the browser window, it gives the user the option to download that to their hard drive, so all you have to do, really, is just point to it. Now you may also notice that throughout the course certain directories are going to have underscores in front of their names. Typically, if there are directories for images or external resources like styles or external scripts, or in this case external assets, I'll put an underscore in front of it. It's a pretty common web practice. There's two reasons for that. Number one, these directories will show up at the top of any list, so it makes it very easy to find them and you don't have to hunt and peck through the alphabetical order of directories in order to find your scripts and your assets and things like that.
But the other thing is that it clearly delineates the contents of this particular directory are not part of the website; in terms of the page structure, they're simply resources. So that's another reason why you might see that frequently within sites. Okay, so the first thing I'm going to do here is create an anchor link, and I'm going to start with the href attribute, and I'm going to point that directly to the ZIP file, and to do that we have to go into the assets directory, so I'm going to do _assets. So remember, we still have to resolve that link, and here I'm going to do syntax.zip, and then remember to close the link tag.
So really, that's nothing that we haven't done already. It's just that instead of pointing to an HTML file, what we're doing is we're pointing to, in this case, a ZIP file. So if I save this and then preview this in my browser, when I click on this link now I'm given the option to go ahead and either try to open this particular file or save it. So this syntax should work with most external resources that you might want to link to, although occasionally you might have a more complex file type that requires some type of additional scripting. You'd be really careful about the types of files that you link to as well.
Users are understandably sensitive about downloading certain file types, so be sure to take that into consideration when linking to external resources.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.