Here is a function for a popup search function, which, when a word is typed, and enter is pressed (the handleKeyPress(e) function, it automatically goes to say, dogs.html (its a kids language learning app). However say they type 'dogg' and not 'dog', Iw ould like it to go to a designated error page. I cannot code at all and have only manipulated other people's scripts. for example, the directory would have a list of animals.html, i.e. dog.html, cat.html, etc. but if a word is typed that is not in this directory
(there should be a search function to see if *.html is there or not, then go to error page if its not there. But I can't do this. I have no training. Can anyone help me with this? I hope I don't get thrown off this forum again, you really shouldn't be so harsh on idiots...!) i.e. what I need is : if .value+'.html' not in dir; goto errorpage.html
Here's "my" code to load whatever word's page that's typed in:
function goTo()
{
location.href = document.getElementById('link_id').value + '.html';
/*window.location.replace("spellcheck.html");*/
}
function handleKeyPress(e){
var key=e.keyCode || e.which;
if (key==13){
goTo();
/*window.location.replace("spellcheck.html"); */
}
}