简体   繁体   中英

How do I get a button to open an HTML file located on my website?

It has been a ling time since i have had to code.

My situation is, i need to make a button that open an HTML file that I have located on my website. The HTML file is a interactive course that will open in a new window.

I have tried <a href="home/file.html" target="_blank"><button>launch Course</button></a> but I get a "page not found" error.

First of all, you don't need to combine the anchor tag with tag. In this case a tag is enough. Also, please check well the path, and verify that the HTML file is in the folder. <a href="path/to/file.html" target="_blank">/Text</a> .

To verify that the file is accessible, and the name and the extension is correct, you can copy and paste the path in the browser to see if you can access it. Links can be absolute (the full path from the root, ex: C:/Users/path/to/folder/file.ext) or relative (the short path from the originating folder). If not, re-write the path until it works.

Tip: for security use rel="noopener noreferrer" to prevent potential malicious attacks .

Happy coding Brandon!

Make sure that your directory with the page you are currently on has the folder home and the html file is located within it.

<a href="home/file.html"></a>

Here's a example directory

/----------
   | index.html(or the current page your on)
   | home -------
           | file.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM