-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
29 lines (26 loc) · 699 Bytes
/
Copy pathscript.js
File metadata and controls
29 lines (26 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Get the search input element
const input = document.getElementById("searchInput");
// Listen for Enter key press
input.addEventListener("keydown", function (event) {
if (event.key === "Enter") {
googleSearch();
}
});
// Google Search button function
function googleSearch() {
const query = input.value.trim();
if (query !== "") {
window.location.href =
"https://www.google.com/search?q=" + encodeURIComponent(query);
}
}
// I'm Feeling Lucky button function
function feelingLucky() {
const query = input.value.trim();
if (query !== "") {
window.location.href =
"https://www.google.com/search?q=" +
encodeURIComponent(query) +
"&btnI=1";
}
}