How can I use js error tags to throw files or other html pages?

I am making a tutorial on HTML and is trying to make such system. There will be a question where you will type in a textbox the correct answer. According to your answer, the computer will display different HTML pages coded in other programs. The problem is that I cannot use the JS error tag to throw pages nor to change the whole page and document.write can change the whole page ,but not to a image.

I tried with

try{
  if(x != "the correct answer")  throw "the link of the wrong page"
  if(x == "the correct answer")  throw "the link of the right page"
}

and instead of throwing a link or changing the HTML page , it just didn’t display anything.

I even knew that JS document.write() erases all HTML if called after the HTML page loads so I tried

<button type="button" onclick=document.write(<a href="the link of the wrong page"></a>)Submit</button>

but then I realized document.write() is uncontrollable (shows the same thing when called) and can’t throw links nor pages.