Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to go to an a Specific HTML when a word is detected (Java)

Java I made an HTML called hello.html and now I want to use the replace() function in Java to go to the HTML page when the word "Covid" is detected on Google, I tried but it doesn’t work for some reason, can you see where I am going wrong, or do I have to change my entire code?

function redirectURL() {
    var specWord = getSpecificWord();

    switch(specWord) 
    {
      case 'corona':
        window.location.replace('hello.html');
        break;
      case 'covid':
        window.location.replace('hello.html');
        break;
      case 'covid-19':
        window.location.replace('hello.html');
        break;
      default:
        return true;
        break;
    }

    return false; // don't let the form submit
}

function getSpecificWord(Element) {
    var specificWord = "corona";
    return specificWord;
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The code does not work since you are not calling the redirectURL function.

Append redirectURL() to your code or use this instead:

(function redirectURL() {
  var specWord = getSpecificWord();
  switch (specWord) {
    case 'corona':
      window.location.replace('hello.html');
      break;
    case 'covid':
      window.location.replace('hello.html');
      break;
    case 'covid-19':
      window.location.replace('hello.html');
      break;
    default:
      return true;
      break;
  }
  return false; //don't let the form submit
})();

function getSpecificWord(Element) {
  var specificWord = 'corona';
  return specificWord;
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading