How can I make an input go to that file

I was wondering how it would be possible to take an HTML input and with javascript make it so that if the user enters 1.html in the input it will take them to the file 1.html?

1 thought on “How can I make an input go to that file”

  1. This is a rough illustration but should give you the general idea. There’s a lot you’d want to add to this but I figure you just want a starting point.

    <input type='text' class='path'>
    <input type='button' class='btn' value='Go!'>
        let btn = document.querySelector('.btn');
        let inputPath = document.querySelector('.path');
        // redirect to chosen path
        btn.addEventListener('click', function(){
            location.href = inputPath.value;

    You may also wish to consult the location object docs.


Leave a Comment