I'm trying to the page to search.html. Depending on what page it is, search.html is either located in the same directory or a directory above. I can't figure out why it's not redirecting.
Here is HTML code:
<form class="search" onsubmit="searchSite()">
<input id="search" title="Seach this site" type="text" name="search"
placeholder="Search this site..">
</form>
Here is JS code:
function searchSite() {
var search = document.getElementById("search").value.toLowerCase().split(" ");
searchArticles(search);
displayResults();
}
function displayResults() {
if (window.location.href.indexOf("humans") !== -1
|| window.location.href.indexOf("other")){
window.location.href = "../search.html";
console.log(window.location.href);}
else
window.location.href = "search.html";
}
Before searching the URL is: file:///C:Desktop/comp266/unit5/public_html/other/other.html
After searching the URL is: file:///C:Desktop/comp266/unit5/public_html/other/other.html ?search=good
But I want the URL to be: file:///C:Desktop/comp266/unit5/public_html/search.html