Im trying to check for a keyword in the url and launch an html file from javascript
here is my code:
window.setInterval(function doTheTing() {
if (window.location.href.indexOf("keyword") > -1) {
window.location.replace("index.html")
}
}, 1000)
what im trying to do is open the file when the keyword is in url, and it does work, but for some reason when i try to open index.html it opens https://www.google.com/index.html instead
*if the keyword is in the url of a youtube video than it opens as https://www.youtube.com/index.html (which isnt a real domain so it just shows an error page)
*if its from a tiktok than https://www.tiktok.com/index.html (which also returns an error page)
and so on…
how can i just open index.html?
thanks for the help