startpage/scr/search.js

20 lines
563 B
JavaScript
Raw Normal View History

2020-11-09 21:24:16 -08:00
window.onload = function() {
this.initSearchBar()
}
function initSearchBar() {
const searchBarInput = document.getElementById("search-bar-input")
searchBarInput.value = ""
searchBarInput.focus()
2020-11-09 21:24:16 -08:00
searchBarInput.addEventListener("keypress", (event) => {
if (event.key !== 'Enter') return
2020-11-09 21:24:16 -08:00
const searchEnginer = "https://www.duckduckgo.com/?q="
const endQuery = "&atb=v225-7&ia=web"
document.location = searchEnginer + searchBarInput.value.replace(/\ /g, "+") + endQuery
2020-11-09 21:24:16 -08:00
})
}