Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can an input field open a new window after pressing enter in Javascript?

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 class="input-group">
     <i class="catalog-search-icon fa-regular fa-magnifying-glass active"></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;
            
            }
        });
    
        });

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading