Menu

1 / 2

Search Bar in a Firefox New Tab Extension: Which Engine, How to Handle

DEV Community·Weather Clock Dash·6 months ago
#E8AM2VvK
Reading 0:00
15s threshold

Search Bar in a Firefox New Tab Extension: Which Engine, How to Handle

Adding a search bar to a new tab extension sounds simple — it's just a text input and a redirect. But there are enough details to get right that it's worth writing down.

The Basic Implementation

<form id= "search-form" role= "search" > <input type= "search" id= "search-input" placeholder= "Search..." autocomplete= "off" autofocus /> </form>

Enter fullscreen mode

Exit fullscreen mode

document . getElementById ( ' search-form ' ). addEventListener ( ' submit ' , e => { e . preventDefault (); const query = document . getElementById ( ' search-input ' ). value . trim (); if ( query ) { window . location .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.