Home > front end >  How can an input field open a new window after pressing enter in Javascript?
How can an input field open a new window after pressing enter in Javascript?

Time:10-20

I have an input field that I need to open a new window after the value is entered and I hit enter. The way I have it right now is after the value is entered it goes to this url https://search.broward.org/texis/search/?pr=FLLComplete&query=' e.target.value in the same window.

<div >
     <i ></i>
          <input type="search" placeholder="Search Airport" aria-label="Search" name="searchterms" title="Search" alt="Search" id="airportSearchInput" size="20">
</div>

    $(document).ready(function() {
        
            $('#airportSearchInput').on("keyup", function(e){
        
                if(e.code === "Enter" || e.key === "Enter") {
                  window.location.href = 'https://search.broward.org/texis/search/?pr=FLLComplete&query='   e.target.value;
            
            }
        });
    
        });

CodePudding user response:

You can use window.open(url) to open your url in a new new tab

  • Related