0

I created links that link two HTML files but one doesn't work.

There is a folder called aiGame which has the aiindex.html (and ai.js and ai.css). index.html is not in a separate folder.

These two lead to the same file but DON'T work. And are in the aiindex.html file in the aiGame folder:

  <button id="twoPlayer" onClick= "location.href='index.html'"> 2 Player </button>

 <a href="index.html"> 2 Player </a>

These two lead to the same file and do work. These two are in the index.html file which is not in a separate folder:

      <button id="aiPlayer" onClick= "location.href='aiGame/aiindex.html'"> Play AI </button>

 <a href="aiGame/aiindex.html"> Play AI </a>

I don't understand why one works but the other doesn't. It could be a mistake with the files. The syntax for linking can't be wrong because there are two ways and they both do not work. Any ideas? Thank You.

Paranoid
  • 25
  • 1
  • 8
  • Does the index.html file exist? – JohnL Jul 23 '19 at 19:44
  • 2
    Yes it does. And I think I solved the problem by putting ../ before index.html ``` ``` – Paranoid Jul 23 '19 at 19:50
  • `The syntax for linking...` Buttons should not be used for navigation. It's semantically incorrect and will cause problems for people who use assistive technologies. Use hyperlinks and, if desired, style them to look like buttons. – Scott Marcus Jul 23 '19 at 19:58

1 Answers1

0

The href you need to go from /aiGame/aiIndex.html to /index.html is either ../index.html or /index.html

cpcolella
  • 247
  • 4
  • 10